openhab-scripting 5.50.0 → 5.51.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b70d205b061cb7bea4228face2481a0ccdb11a9947c8b4194b972db0a15c6935
4
- data.tar.gz: 60ac7bf7347d4027766fc0285e61bcb849203196e2d625e8181da4e04e96c220
3
+ metadata.gz: f53f1018eaf8a1915bbfe5897cbe0ba0985c1ce0497bd8eacb03f7b09aaa2e2c
4
+ data.tar.gz: 458412ea19dc5cfd6e351e4cdd656b14cfd5184f84503cb27b9abfc9aaeec05c
5
5
  SHA512:
6
- metadata.gz: 13014e726aa0efe66e5e1034f31f0a5c6688c7e19373cd314dfc93145137ce9232b8fa710c889b69dc2f07f18b109649f73fb20e720bde56e5bee8b10168601e
7
- data.tar.gz: 264e3d3d6b351e466b9317728fabf1f086addbd6318ab1a349d57b711a7d26559cf85d8619d8b41cd31969edf7af8dda844ffad128f6edce6cb00538fba8cf15
6
+ metadata.gz: 0be40fe6f7188db7f896017a78ec4c42b3259811ae2bf5a63ca3c95f9ce26f8fd414e847610cb586987fcf94f1ef0e7848f621a19c04b38cb060ea4dac163fec
7
+ data.tar.gz: d345bb2045d9c30b4e356454acd499732ac8c0ca6ec588e960d3baccd10706b4e5759d4b5dabe66942476cca9b8fb4041b64d618187c4c7bb47c839a90d445af
@@ -173,18 +173,34 @@ module OpenHAB
173
173
  # Manually trigger the rule
174
174
  #
175
175
  # @param [Object, nil] event The event to pass to the rule's execution blocks.
176
+ # @param [Boolean] async Run the rule asynchronously.
177
+ # When `true`, the method returns right away and the rule continues running in a separate thread.
176
178
  # @param [Boolean] consider_conditions Whether to check the conditions of the called rules.
177
179
  # @param [kwargs] context The context to pass to the conditions and the actions of the rule.
178
- # @return [Hash] A copy of the rule context, including possible return values.
180
+ # @return [Hash, java.util.concurrent.Future<Hash>] A copy of the rule context,
181
+ # including possible return values.
182
+ # When `async` is true, a {java.util.concurrent.Future Future} object is returned
183
+ # that will resolve to the context once the rule has finished executing.
184
+ # To wait for the rule to complete and retrieve the context, call `#get` on the returned Future.
185
+ # @raise [NotImplementedError] if asynchronous execution isn't supported by the `RuleManager` implementation.
179
186
  #
180
- def trigger(event = nil, consider_conditions: false, **context)
187
+ # @since openHAB 5.2 The `async` parameter was added to enable asynchronous rule execution.
188
+ #
189
+ def trigger(event = nil, async: false, consider_conditions: false, **context)
181
190
  event ||= org.openhab.core.automation.events.AutomationEventFactory
182
191
  .createExecutionEvent(uid, nil, "manual")
183
192
  context.transform_keys!(&:to_s)
184
193
  # Unwrap any proxies and pass raw objects (items, things)
185
194
  context.transform_values! { |value| value.is_a?(Delegator) ? value.__getobj__ : value }
186
195
  context["event"] = event
187
- Rules.manager.run_now(uid, consider_conditions, context)
196
+
197
+ return Rules.manager.run_now(uid, consider_conditions, context) unless async
198
+
199
+ begin
200
+ Rules.manager.run_async(uid, consider_conditions, context)
201
+ rescue java.lang.UnsupportedOperationException, NoMethodError
202
+ raise NotImplementedError
203
+ end
188
204
  end
189
205
  alias_method :run, :trigger
190
206
  end
data/lib/openhab/core.rb CHANGED
@@ -156,6 +156,42 @@ module OpenHAB
156
156
  ]
157
157
  end.freeze
158
158
  end
159
+
160
+ #
161
+ # Returns the current start level of the openHAB runtime.
162
+ #
163
+ # Start levels represent runtime startup progress as integer values:
164
+ #
165
+ # - `10` - OSGi application start level reached (bundles activated).
166
+ # - `20` - Model entities (items, things, links, persistence config) loaded.
167
+ # - `30` - Item states restored from persistence service, where applicable.
168
+ # - `40` - Rules loaded and parsed; script engine factories available.
169
+ # - `50` - Rule engine executed all "system started" rules and is active.
170
+ # - `70` - User interface is up and running.
171
+ # - `80` - All things have been initialized.
172
+ # - `100` - Startup is fully complete.
173
+ #
174
+ # @example Checking if startup is complete
175
+ # if OpenHAB::Core.startlevel == 100
176
+ # logger.info "openHAB startup complete!"
177
+ # end
178
+ #
179
+ # @example Checking if things are initialized
180
+ # if OpenHAB::Core.startlevel >= 80
181
+ # logger.info "Things are ready."
182
+ # end
183
+ #
184
+ # @return [Integer, nil] The current start level integer, or `nil` if the
185
+ # StartLevelService is unavailable.
186
+ #
187
+ # @see OpenHAB::DSL::Rules::BuilderDSL#on_start on_start rule trigger
188
+ # @see OpenHAB::Core::Events::StartlevelEvent StartlevelEvent
189
+ #
190
+ def startlevel
191
+ @start_level_service ||= OSGi.service("org.openhab.core.service.StartLevelService")
192
+ @start_level_service&.start_level
193
+ end
194
+ alias_method :start_level, :startlevel
159
195
  end
160
196
 
161
197
  import_default_presets unless defined?($ir)
@@ -1512,6 +1512,8 @@ module OpenHAB
1512
1512
  # end
1513
1513
  #
1514
1514
  # @see https://www.openhab.org/docs/configuration/rules-dsl.html#system-based-triggers System based triggers
1515
+ # @see OpenHAB::Core::Events::StartlevelEvent
1516
+ # @see OpenHAB::Core.startlevel
1515
1517
  #
1516
1518
  def on_start(at_level: nil, at_levels: nil, attach: nil)
1517
1519
  levels = Array.wrap(at_level) | Array.wrap(at_levels)
@@ -4,6 +4,6 @@ module OpenHAB
4
4
  module DSL
5
5
  # Version of openHAB helper libraries
6
6
  # @return [String]
7
- VERSION = "5.50.0"
7
+ VERSION = "5.51.0"
8
8
  end
9
9
  end
@@ -366,6 +366,7 @@ module OpenHAB
366
366
  "org.openhab.core.model.rule.runtime" => nil,
367
367
  "org.openhab.core.model.rule" => nil,
368
368
  "org.openhab.core.model.sitemap.runtime" => nil,
369
+ "org.openhab.core.ui" => nil,
369
370
  "org.openhab.core.voice" => nil
370
371
  }.freeze
371
372
  private_constant :BLOCKED_COMPONENTS
@@ -805,11 +806,14 @@ module OpenHAB
805
806
  <f:feature>openhab-core-model-script</f:feature>
806
807
  <f:feature>openhab-core-model-sitemap</f:feature>
807
808
  <f:feature>openhab-core-model-thing</f:feature>
809
+ <f:feature>openhab-core-model-yaml</f:feature>
808
810
  <f:feature>openhab-core-storage-json</f:feature>
809
811
  <f:feature>openhab-core-ui-icon</f:feature>
810
812
  <f:feature>openhab-transport-http</f:feature>
811
813
  <f:feature prerequisite="true">wrapper</f:feature>
812
814
  <f:bundle>mvn:org.openhab.core.bundles/org.openhab.core.karaf/#{version}</f:bundle>
815
+ <!-- openhab-core-model-yaml imports org.openhab.core.ui.components since OH 5.2 -->
816
+ <f:bundle>mvn:org.openhab.core.bundles/org.openhab.core.ui/#{version}</f:bundle>
813
817
  </feature>
814
818
  </replacement>
815
819
  </featureReplacements>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openhab-scripting
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.50.0
4
+ version: 5.51.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian O'Connell
@@ -11,6 +11,20 @@ bindir: bin
11
11
  cert_chain: []
12
12
  date: 1980-01-02 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bigdecimal
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '4.0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '4.0'
14
28
  - !ruby/object:Gem::Dependency
15
29
  name: bundler
16
30
  requirement: !ruby/object:Gem::Requirement
@@ -31,6 +45,34 @@ dependencies:
31
45
  - - "<"
32
46
  - !ruby/object:Gem::Version
33
47
  version: '5.0'
48
+ - !ruby/object:Gem::Dependency
49
+ name: csv
50
+ requirement: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: irb
64
+ requirement: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.4'
69
+ type: :runtime
70
+ prerelease: false
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.4'
34
76
  - !ruby/object:Gem::Dependency
35
77
  name: marcel
36
78
  requirement: !ruby/object:Gem::Requirement
@@ -361,7 +403,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
361
403
  - !ruby/object:Gem::Version
362
404
  version: '0'
363
405
  requirements: []
364
- rubygems_version: 4.0.16
406
+ rubygems_version: 4.0.18
365
407
  specification_version: 4
366
408
  summary: JRuby Helper Libraries for openHAB Scripting
367
409
  test_files: []