openhab-scripting 2.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/workflow.yml +327 -0
  3. data/.gitignore +17 -0
  4. data/.java-version +1 -0
  5. data/.rspec +1 -0
  6. data/.yardopts +1 -0
  7. data/CHANGELOG.md +113 -0
  8. data/Gemfile +28 -0
  9. data/Gemfile.lock +245 -0
  10. data/Guardfile +35 -0
  11. data/LICENSE +277 -0
  12. data/README.md +23 -0
  13. data/Rakefile +406 -0
  14. data/bin/console +15 -0
  15. data/bin/setup +8 -0
  16. data/config/userdata/config/org/openhab/restauth.config +3 -0
  17. data/cucumber.yml +1 -0
  18. data/docs/_config.yml +135 -0
  19. data/docs/contributing/index.md +47 -0
  20. data/docs/examples/conversions.md +123 -0
  21. data/docs/examples/index.md +61 -0
  22. data/docs/index.md +19 -0
  23. data/docs/installation/index.md +26 -0
  24. data/docs/motivation/index.md +27 -0
  25. data/docs/usage/execution.md +9 -0
  26. data/docs/usage/execution/delay.md +48 -0
  27. data/docs/usage/execution/otherwise.md +30 -0
  28. data/docs/usage/execution/run.md +70 -0
  29. data/docs/usage/execution/triggered.md +48 -0
  30. data/docs/usage/guards.md +51 -0
  31. data/docs/usage/guards/between.md +30 -0
  32. data/docs/usage/guards/not_if.md +41 -0
  33. data/docs/usage/guards/only_if.md +40 -0
  34. data/docs/usage/index.md +11 -0
  35. data/docs/usage/items.md +66 -0
  36. data/docs/usage/items/contact.md +84 -0
  37. data/docs/usage/items/dimmer.md +147 -0
  38. data/docs/usage/items/groups.md +76 -0
  39. data/docs/usage/items/number.md +225 -0
  40. data/docs/usage/items/string.md +49 -0
  41. data/docs/usage/items/switch.md +85 -0
  42. data/docs/usage/misc.md +7 -0
  43. data/docs/usage/misc/actions.md +108 -0
  44. data/docs/usage/misc/duration.md +21 -0
  45. data/docs/usage/misc/gems.md +25 -0
  46. data/docs/usage/misc/logging.md +21 -0
  47. data/docs/usage/misc/metadata.md +128 -0
  48. data/docs/usage/misc/store_states.md +42 -0
  49. data/docs/usage/misc/time_of_day.md +69 -0
  50. data/docs/usage/misc/timers.md +67 -0
  51. data/docs/usage/rule.md +43 -0
  52. data/docs/usage/things.md +29 -0
  53. data/docs/usage/triggers.md +8 -0
  54. data/docs/usage/triggers/changed.md +57 -0
  55. data/docs/usage/triggers/channel.md +54 -0
  56. data/docs/usage/triggers/command.md +69 -0
  57. data/docs/usage/triggers/cron.md +19 -0
  58. data/docs/usage/triggers/every.md +76 -0
  59. data/docs/usage/triggers/updated.md +78 -0
  60. data/lib/openhab.rb +39 -0
  61. data/lib/openhab/configuration.rb +16 -0
  62. data/lib/openhab/core/cron.rb +27 -0
  63. data/lib/openhab/core/debug.rb +34 -0
  64. data/lib/openhab/core/dsl.rb +47 -0
  65. data/lib/openhab/core/dsl/actions.rb +107 -0
  66. data/lib/openhab/core/dsl/entities.rb +103 -0
  67. data/lib/openhab/core/dsl/gems.rb +29 -0
  68. data/lib/openhab/core/dsl/group.rb +91 -0
  69. data/lib/openhab/core/dsl/items/items.rb +39 -0
  70. data/lib/openhab/core/dsl/items/number_item.rb +217 -0
  71. data/lib/openhab/core/dsl/items/string_item.rb +102 -0
  72. data/lib/openhab/core/dsl/monkey_patch/actions/actions.rb +4 -0
  73. data/lib/openhab/core/dsl/monkey_patch/actions/script_thing_actions.rb +22 -0
  74. data/lib/openhab/core/dsl/monkey_patch/events.rb +5 -0
  75. data/lib/openhab/core/dsl/monkey_patch/events/item_command.rb +13 -0
  76. data/lib/openhab/core/dsl/monkey_patch/events/item_state_changed.rb +25 -0
  77. data/lib/openhab/core/dsl/monkey_patch/events/thing_status_info.rb +26 -0
  78. data/lib/openhab/core/dsl/monkey_patch/items/contact_item.rb +54 -0
  79. data/lib/openhab/core/dsl/monkey_patch/items/dimmer_item.rb +125 -0
  80. data/lib/openhab/core/dsl/monkey_patch/items/group_item.rb +27 -0
  81. data/lib/openhab/core/dsl/monkey_patch/items/items.rb +130 -0
  82. data/lib/openhab/core/dsl/monkey_patch/items/metadata.rb +259 -0
  83. data/lib/openhab/core/dsl/monkey_patch/items/switch_item.rb +86 -0
  84. data/lib/openhab/core/dsl/monkey_patch/ruby/number.rb +69 -0
  85. data/lib/openhab/core/dsl/monkey_patch/ruby/range.rb +46 -0
  86. data/lib/openhab/core/dsl/monkey_patch/ruby/ruby.rb +5 -0
  87. data/lib/openhab/core/dsl/monkey_patch/types/decimal_type.rb +24 -0
  88. data/lib/openhab/core/dsl/monkey_patch/types/on_off_type.rb +41 -0
  89. data/lib/openhab/core/dsl/monkey_patch/types/open_closed_type.rb +25 -0
  90. data/lib/openhab/core/dsl/monkey_patch/types/percent_type.rb +23 -0
  91. data/lib/openhab/core/dsl/monkey_patch/types/types.rb +7 -0
  92. data/lib/openhab/core/dsl/property.rb +85 -0
  93. data/lib/openhab/core/dsl/rule/channel.rb +41 -0
  94. data/lib/openhab/core/dsl/rule/cron.rb +115 -0
  95. data/lib/openhab/core/dsl/rule/guard.rb +99 -0
  96. data/lib/openhab/core/dsl/rule/item.rb +207 -0
  97. data/lib/openhab/core/dsl/rule/rule.rb +374 -0
  98. data/lib/openhab/core/dsl/rule/triggers.rb +77 -0
  99. data/lib/openhab/core/dsl/states.rb +63 -0
  100. data/lib/openhab/core/dsl/things.rb +93 -0
  101. data/lib/openhab/core/dsl/time_of_day.rb +203 -0
  102. data/lib/openhab/core/dsl/timers.rb +85 -0
  103. data/lib/openhab/core/dsl/types/quantity.rb +255 -0
  104. data/lib/openhab/core/dsl/units.rb +41 -0
  105. data/lib/openhab/core/duration.rb +69 -0
  106. data/lib/openhab/core/log.rb +175 -0
  107. data/lib/openhab/core/patch_load_path.rb +7 -0
  108. data/lib/openhab/core/startup_delay.rb +22 -0
  109. data/lib/openhab/osgi.rb +52 -0
  110. data/lib/openhab/version.rb +9 -0
  111. data/openhab-scripting.gemspec +30 -0
  112. data/openhab_rules/warmup.rb +5 -0
  113. metadata +157 -0
@@ -0,0 +1,7 @@
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
@@ -0,0 +1,22 @@
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
+ CHECK_DELAY = 10
12
+ private_constant :CHECK_DELAY
13
+
14
+ logger.info('Checking for Automation manager')
15
+ # rubocop: disable Style/GlobalVars
16
+ until $scriptExtension.get('automationManager')
17
+ logger.info("Automation manager not loaded, checking again in #{CHECK_DELAY} seconds.")
18
+ sleep CHECK_DELAY
19
+ end
20
+ # rubocop: enable Style/GlobalVars
21
+ logger.info 'Automation manager check complete.'
22
+ end
@@ -0,0 +1,52 @@
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
+ def self.bundle_context
42
+ @bundle_context ||= bundle.getBundleContext
43
+ end
44
+ private_class_method :bundle_context
45
+
46
+ # Get the OSGI Bundle for ScriptExtension Class
47
+ def self.bundle
48
+ @bundle ||= FrameworkUtil.getBundle($scriptExtension.class)
49
+ end
50
+ private_class_method :bundle
51
+ end
52
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ # Holds project version constant
5
+ #
6
+ module OpenHAB
7
+ # @return [String] Version of OpenHAB helper libraries
8
+ VERSION = '2.9.1'
9
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/openhab/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'openhab-scripting'
7
+ spec.version = OpenHAB::VERSION
8
+ spec.authors = ["Brian O'Connell"]
9
+ spec.email = ['broconne@gmail.com']
10
+
11
+ spec.summary = 'JRuby Helper Libraries for OpenHAB Scripting'
12
+ spec.description = 'JRuby Helper Libraries for OpenHAB Scripting'
13
+ spec.homepage = 'https://boc-tothefuture.github.io/openhab-jruby/'
14
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
15
+
16
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
17
+
18
+ spec.metadata['homepage_uri'] = spec.homepage
19
+ spec.metadata['source_code_uri'] = 'https://github.com/boc-tothefuture/openhab-jruby'
20
+ spec.metadata['changelog_uri'] = 'https://github.com/boc-tothefuture/openhab-jruby/blob/main/CHANGELOG.md'
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
25
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|bundle)/}) }
26
+ end
27
+ spec.bindir = 'exe'
28
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ['lib']
30
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'openhab'
4
+
5
+ logger.info('OpenHAB warmup complete')
metadata ADDED
@@ -0,0 +1,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: openhab-scripting
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.9.1
5
+ platform: ruby
6
+ authors:
7
+ - Brian O'Connell
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-01-28 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: JRuby Helper Libraries for OpenHAB Scripting
14
+ email:
15
+ - broconne@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".github/workflows/workflow.yml"
21
+ - ".gitignore"
22
+ - ".java-version"
23
+ - ".rspec"
24
+ - ".yardopts"
25
+ - CHANGELOG.md
26
+ - Gemfile
27
+ - Gemfile.lock
28
+ - Guardfile
29
+ - LICENSE
30
+ - README.md
31
+ - Rakefile
32
+ - bin/console
33
+ - bin/setup
34
+ - config/userdata/config/org/openhab/restauth.config
35
+ - cucumber.yml
36
+ - docs/_config.yml
37
+ - docs/contributing/index.md
38
+ - docs/examples/conversions.md
39
+ - docs/examples/index.md
40
+ - docs/index.md
41
+ - docs/installation/index.md
42
+ - docs/motivation/index.md
43
+ - docs/usage/execution.md
44
+ - docs/usage/execution/delay.md
45
+ - docs/usage/execution/otherwise.md
46
+ - docs/usage/execution/run.md
47
+ - docs/usage/execution/triggered.md
48
+ - docs/usage/guards.md
49
+ - docs/usage/guards/between.md
50
+ - docs/usage/guards/not_if.md
51
+ - docs/usage/guards/only_if.md
52
+ - docs/usage/index.md
53
+ - docs/usage/items.md
54
+ - docs/usage/items/contact.md
55
+ - docs/usage/items/dimmer.md
56
+ - docs/usage/items/groups.md
57
+ - docs/usage/items/number.md
58
+ - docs/usage/items/string.md
59
+ - docs/usage/items/switch.md
60
+ - docs/usage/misc.md
61
+ - docs/usage/misc/actions.md
62
+ - docs/usage/misc/duration.md
63
+ - docs/usage/misc/gems.md
64
+ - docs/usage/misc/logging.md
65
+ - docs/usage/misc/metadata.md
66
+ - docs/usage/misc/store_states.md
67
+ - docs/usage/misc/time_of_day.md
68
+ - docs/usage/misc/timers.md
69
+ - docs/usage/rule.md
70
+ - docs/usage/things.md
71
+ - docs/usage/triggers.md
72
+ - docs/usage/triggers/changed.md
73
+ - docs/usage/triggers/channel.md
74
+ - docs/usage/triggers/command.md
75
+ - docs/usage/triggers/cron.md
76
+ - docs/usage/triggers/every.md
77
+ - docs/usage/triggers/updated.md
78
+ - lib/openhab.rb
79
+ - lib/openhab/configuration.rb
80
+ - lib/openhab/core/cron.rb
81
+ - lib/openhab/core/debug.rb
82
+ - lib/openhab/core/dsl.rb
83
+ - lib/openhab/core/dsl/actions.rb
84
+ - lib/openhab/core/dsl/entities.rb
85
+ - lib/openhab/core/dsl/gems.rb
86
+ - lib/openhab/core/dsl/group.rb
87
+ - lib/openhab/core/dsl/items/items.rb
88
+ - lib/openhab/core/dsl/items/number_item.rb
89
+ - lib/openhab/core/dsl/items/string_item.rb
90
+ - lib/openhab/core/dsl/monkey_patch/actions/actions.rb
91
+ - lib/openhab/core/dsl/monkey_patch/actions/script_thing_actions.rb
92
+ - lib/openhab/core/dsl/monkey_patch/events.rb
93
+ - lib/openhab/core/dsl/monkey_patch/events/item_command.rb
94
+ - lib/openhab/core/dsl/monkey_patch/events/item_state_changed.rb
95
+ - lib/openhab/core/dsl/monkey_patch/events/thing_status_info.rb
96
+ - lib/openhab/core/dsl/monkey_patch/items/contact_item.rb
97
+ - lib/openhab/core/dsl/monkey_patch/items/dimmer_item.rb
98
+ - lib/openhab/core/dsl/monkey_patch/items/group_item.rb
99
+ - lib/openhab/core/dsl/monkey_patch/items/items.rb
100
+ - lib/openhab/core/dsl/monkey_patch/items/metadata.rb
101
+ - lib/openhab/core/dsl/monkey_patch/items/switch_item.rb
102
+ - lib/openhab/core/dsl/monkey_patch/ruby/number.rb
103
+ - lib/openhab/core/dsl/monkey_patch/ruby/range.rb
104
+ - lib/openhab/core/dsl/monkey_patch/ruby/ruby.rb
105
+ - lib/openhab/core/dsl/monkey_patch/types/decimal_type.rb
106
+ - lib/openhab/core/dsl/monkey_patch/types/on_off_type.rb
107
+ - lib/openhab/core/dsl/monkey_patch/types/open_closed_type.rb
108
+ - lib/openhab/core/dsl/monkey_patch/types/percent_type.rb
109
+ - lib/openhab/core/dsl/monkey_patch/types/types.rb
110
+ - lib/openhab/core/dsl/property.rb
111
+ - lib/openhab/core/dsl/rule/channel.rb
112
+ - lib/openhab/core/dsl/rule/cron.rb
113
+ - lib/openhab/core/dsl/rule/guard.rb
114
+ - lib/openhab/core/dsl/rule/item.rb
115
+ - lib/openhab/core/dsl/rule/rule.rb
116
+ - lib/openhab/core/dsl/rule/triggers.rb
117
+ - lib/openhab/core/dsl/states.rb
118
+ - lib/openhab/core/dsl/things.rb
119
+ - lib/openhab/core/dsl/time_of_day.rb
120
+ - lib/openhab/core/dsl/timers.rb
121
+ - lib/openhab/core/dsl/types/quantity.rb
122
+ - lib/openhab/core/dsl/units.rb
123
+ - lib/openhab/core/duration.rb
124
+ - lib/openhab/core/log.rb
125
+ - lib/openhab/core/patch_load_path.rb
126
+ - lib/openhab/core/startup_delay.rb
127
+ - lib/openhab/osgi.rb
128
+ - lib/openhab/version.rb
129
+ - openhab-scripting.gemspec
130
+ - openhab_rules/warmup.rb
131
+ homepage: https://boc-tothefuture.github.io/openhab-jruby/
132
+ licenses: []
133
+ metadata:
134
+ homepage_uri: https://boc-tothefuture.github.io/openhab-jruby/
135
+ source_code_uri: https://github.com/boc-tothefuture/openhab-jruby
136
+ changelog_uri: https://github.com/boc-tothefuture/openhab-jruby/blob/main/CHANGELOG.md
137
+ post_install_message:
138
+ rdoc_options: []
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: 2.5.0
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ requirements: []
152
+ rubyforge_project:
153
+ rubygems_version: 2.7.6.2
154
+ signing_key:
155
+ specification_version: 4
156
+ summary: JRuby Helper Libraries for OpenHAB Scripting
157
+ test_files: []