openhab-scripting 2.14.3 → 2.16.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/lib/openhab.rb +12 -16
  3. data/lib/openhab/core/entity_lookup.rb +162 -0
  4. data/lib/openhab/core/openhab_setup.rb +31 -0
  5. data/lib/openhab/core/osgi.rb +61 -0
  6. data/lib/openhab/dsl/actions.rb +105 -0
  7. data/lib/openhab/dsl/dsl.rb +47 -0
  8. data/lib/openhab/{core/dsl → dsl}/gems.rb +0 -1
  9. data/lib/openhab/dsl/group.rb +100 -0
  10. data/lib/openhab/dsl/items/items.rb +46 -0
  11. data/lib/openhab/dsl/items/number_item.rb +352 -0
  12. data/lib/openhab/dsl/items/string_item.rb +120 -0
  13. data/lib/openhab/dsl/monkey_patch/actions/actions.rb +4 -0
  14. data/lib/openhab/dsl/monkey_patch/actions/script_thing_actions.rb +32 -0
  15. data/lib/openhab/dsl/monkey_patch/events/events.rb +5 -0
  16. data/lib/openhab/dsl/monkey_patch/events/item_command.rb +23 -0
  17. data/lib/openhab/dsl/monkey_patch/events/item_state_changed.rb +35 -0
  18. data/lib/openhab/dsl/monkey_patch/events/thing_status_info.rb +33 -0
  19. data/lib/openhab/dsl/monkey_patch/items/contact_item.rb +61 -0
  20. data/lib/openhab/dsl/monkey_patch/items/dimmer_item.rb +193 -0
  21. data/lib/openhab/dsl/monkey_patch/items/group_item.rb +37 -0
  22. data/lib/openhab/dsl/monkey_patch/items/items.rb +133 -0
  23. data/lib/openhab/dsl/monkey_patch/items/metadata.rb +281 -0
  24. data/lib/openhab/dsl/monkey_patch/items/persistence.rb +70 -0
  25. data/lib/openhab/dsl/monkey_patch/items/switch_item.rb +95 -0
  26. data/lib/openhab/dsl/monkey_patch/ruby/number.rb +39 -0
  27. data/lib/openhab/dsl/monkey_patch/ruby/range.rb +47 -0
  28. data/lib/openhab/dsl/monkey_patch/ruby/ruby.rb +7 -0
  29. data/lib/openhab/dsl/monkey_patch/ruby/string.rb +41 -0
  30. data/lib/openhab/dsl/monkey_patch/types/decimal_type.rb +70 -0
  31. data/lib/openhab/dsl/monkey_patch/types/on_off_type.rb +51 -0
  32. data/lib/openhab/dsl/monkey_patch/types/open_closed_type.rb +36 -0
  33. data/lib/openhab/dsl/monkey_patch/types/percent_type.rb +32 -0
  34. data/lib/openhab/dsl/monkey_patch/types/quantity_type.rb +69 -0
  35. data/lib/openhab/dsl/monkey_patch/types/types.rb +8 -0
  36. data/lib/openhab/dsl/persistence.rb +25 -0
  37. data/lib/openhab/dsl/rules/automation_rule.rb +342 -0
  38. data/lib/openhab/dsl/rules/guard.rb +134 -0
  39. data/lib/openhab/dsl/rules/property.rb +102 -0
  40. data/lib/openhab/dsl/rules/rule.rb +116 -0
  41. data/lib/openhab/dsl/rules/rule_config.rb +151 -0
  42. data/lib/openhab/dsl/rules/triggers/changed.rb +143 -0
  43. data/lib/openhab/dsl/rules/triggers/channel.rb +53 -0
  44. data/lib/openhab/dsl/rules/triggers/command.rb +104 -0
  45. data/lib/openhab/dsl/rules/triggers/cron.rb +177 -0
  46. data/lib/openhab/dsl/rules/triggers/trigger.rb +124 -0
  47. data/lib/openhab/dsl/rules/triggers/updated.rb +98 -0
  48. data/lib/openhab/dsl/states.rb +61 -0
  49. data/lib/openhab/dsl/things.rb +91 -0
  50. data/lib/openhab/dsl/time_of_day.rb +228 -0
  51. data/lib/openhab/dsl/timers.rb +77 -0
  52. data/lib/openhab/dsl/types/quantity.rb +290 -0
  53. data/lib/openhab/dsl/units.rb +39 -0
  54. data/lib/openhab/log/configuration.rb +21 -0
  55. data/lib/openhab/log/logger.rb +172 -0
  56. data/lib/openhab/version.rb +1 -1
  57. metadata +55 -54
  58. data/lib/openhab/configuration.rb +0 -16
  59. data/lib/openhab/core/cron.rb +0 -27
  60. data/lib/openhab/core/debug.rb +0 -34
  61. data/lib/openhab/core/dsl.rb +0 -47
  62. data/lib/openhab/core/dsl/actions.rb +0 -107
  63. data/lib/openhab/core/dsl/entities.rb +0 -140
  64. data/lib/openhab/core/dsl/group.rb +0 -93
  65. data/lib/openhab/core/dsl/items/items.rb +0 -51
  66. data/lib/openhab/core/dsl/items/number_item.rb +0 -318
  67. data/lib/openhab/core/dsl/items/string_item.rb +0 -120
  68. data/lib/openhab/core/dsl/monkey_patch/actions/actions.rb +0 -4
  69. data/lib/openhab/core/dsl/monkey_patch/actions/script_thing_actions.rb +0 -22
  70. data/lib/openhab/core/dsl/monkey_patch/events.rb +0 -5
  71. data/lib/openhab/core/dsl/monkey_patch/events/item_command.rb +0 -13
  72. data/lib/openhab/core/dsl/monkey_patch/events/item_state_changed.rb +0 -25
  73. data/lib/openhab/core/dsl/monkey_patch/events/thing_status_info.rb +0 -26
  74. data/lib/openhab/core/dsl/monkey_patch/items/contact_item.rb +0 -54
  75. data/lib/openhab/core/dsl/monkey_patch/items/dimmer_item.rb +0 -167
  76. data/lib/openhab/core/dsl/monkey_patch/items/group_item.rb +0 -27
  77. data/lib/openhab/core/dsl/monkey_patch/items/items.rb +0 -130
  78. data/lib/openhab/core/dsl/monkey_patch/items/metadata.rb +0 -283
  79. data/lib/openhab/core/dsl/monkey_patch/items/switch_item.rb +0 -87
  80. data/lib/openhab/core/dsl/monkey_patch/ruby/number.rb +0 -41
  81. data/lib/openhab/core/dsl/monkey_patch/ruby/range.rb +0 -47
  82. data/lib/openhab/core/dsl/monkey_patch/ruby/ruby.rb +0 -6
  83. data/lib/openhab/core/dsl/monkey_patch/types/decimal_type.rb +0 -24
  84. data/lib/openhab/core/dsl/monkey_patch/types/on_off_type.rb +0 -41
  85. data/lib/openhab/core/dsl/monkey_patch/types/open_closed_type.rb +0 -25
  86. data/lib/openhab/core/dsl/monkey_patch/types/percent_type.rb +0 -23
  87. data/lib/openhab/core/dsl/monkey_patch/types/types.rb +0 -7
  88. data/lib/openhab/core/dsl/property.rb +0 -96
  89. data/lib/openhab/core/dsl/rule/automation_rule.rb +0 -348
  90. data/lib/openhab/core/dsl/rule/guard.rb +0 -136
  91. data/lib/openhab/core/dsl/rule/rule.rb +0 -117
  92. data/lib/openhab/core/dsl/rule/rule_config.rb +0 -153
  93. data/lib/openhab/core/dsl/rule/triggers/changed.rb +0 -145
  94. data/lib/openhab/core/dsl/rule/triggers/channel.rb +0 -55
  95. data/lib/openhab/core/dsl/rule/triggers/command.rb +0 -106
  96. data/lib/openhab/core/dsl/rule/triggers/cron.rb +0 -160
  97. data/lib/openhab/core/dsl/rule/triggers/trigger.rb +0 -126
  98. data/lib/openhab/core/dsl/rule/triggers/updated.rb +0 -100
  99. data/lib/openhab/core/dsl/states.rb +0 -63
  100. data/lib/openhab/core/dsl/things.rb +0 -93
  101. data/lib/openhab/core/dsl/time_of_day.rb +0 -229
  102. data/lib/openhab/core/dsl/timers.rb +0 -79
  103. data/lib/openhab/core/dsl/types/quantity.rb +0 -292
  104. data/lib/openhab/core/dsl/units.rb +0 -41
  105. data/lib/openhab/core/log.rb +0 -170
  106. data/lib/openhab/core/patch_load_path.rb +0 -7
  107. data/lib/openhab/core/startup_delay.rb +0 -23
  108. data/lib/openhab/osgi.rb +0 -59
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # The following module patches the load path to include distributed ruby files
4
- module PatchLoadPath
5
- lib_path = File.realpath(File.join(__dir__, '..'))
6
- $LOAD_PATH << lib_path unless $LOAD_PATH.include?(lib_path)
7
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'core/log'
4
-
5
- #
6
- # Module when included will pause the current thread until OpenHAB is ready for interaction
7
- #
8
- module StartupDelay
9
- include Logging
10
-
11
- # @return [Integer] Number of seconds to wait between checks for automation manager
12
- CHECK_DELAY = 10
13
- private_constant :CHECK_DELAY
14
-
15
- logger.info('Checking for Automation manager')
16
- # rubocop: disable Style/GlobalVars
17
- until $scriptExtension.get('automationManager')
18
- logger.info("Automation manager not loaded, checking again in #{CHECK_DELAY} seconds.")
19
- sleep CHECK_DELAY
20
- end
21
- # rubocop: enable Style/GlobalVars
22
- logger.info 'Automation manager check complete.'
23
- end
data/lib/openhab/osgi.rb DELETED
@@ -1,59 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'java'
4
- require 'openhab/core/log'
5
-
6
- module OpenHAB
7
- #
8
- # OSGI services interface
9
- #
10
- class OSGI
11
- include Logging
12
-
13
- java_import org.openhab.core.model.script.actions.ScriptExecution
14
- java_import org.osgi.framework.FrameworkUtil
15
-
16
- #
17
- # @param name [String] The service name
18
- #
19
- # @return [Service]
20
- #
21
- def self.service(name)
22
- ref = bundle_context.getServiceReference(name)
23
- service = bundle_context.getService(ref) if ref
24
- logger.trace "OSGI service(#{service}) found for '#{name}' using OSGI Service Reference #{ref}"
25
-
26
- service
27
- end
28
-
29
- #
30
- # @param name [String] The service name
31
- # @param filter [String] Filter for service names. See https://docs.osgi.org/javadoc/r4v43/core/org/osgi/framework/Filter.html
32
- #
33
- # @return [Array] An array of services
34
- #
35
- def self.services(name, filter: nil)
36
- bundle_context.getServiceReferences(name, filter)&.map do |reference|
37
- bundle_context.getService(reference)
38
- end
39
- end
40
-
41
- #
42
- # Get the bundle context
43
- #
44
- # @return [java::org::osgi::framework::BundleContext] OSGI bundle context
45
- #
46
- def self.bundle_context
47
- @bundle_context ||= bundle.getBundleContext
48
- end
49
- private_class_method :bundle_context
50
-
51
- # Get the OSGI Bundle for ScriptExtension Class
52
- def self.bundle
53
- # rubocop: disable Style/GlobalVars
54
- @bundle ||= FrameworkUtil.getBundle($scriptExtension.class)
55
- # rubocop: enable Style/GlobalVars
56
- end
57
- private_class_method :bundle
58
- end
59
- end