openhab-scripting 5.4.2 → 5.5.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 +4 -4
- data/lib/openhab/core/items/persistence.rb +45 -12
- data/lib/openhab/dsl/rules/triggers/conditions/duration.rb +2 -1
- data/lib/openhab/dsl/rules/triggers/conditions/generic.rb +7 -0
- data/lib/openhab/dsl/version.rb +1 -1
- data/lib/openhab/log.rb +2 -2
- data/lib/openhab/rspec/helpers.rb +10 -1
- data/lib/openhab/rspec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9b21bcd2b958405fb4b4843435e3a6ffa14690af1b6f58139897982a7d55323f
|
|
4
|
+
data.tar.gz: a1c258192db348813c49b94e21492771d9b2e7d6515e6aff0e04b5bba7786711
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 81fd4bfaa0f3cb1907622938750dc0eabcc51b0d46d8ad39fd63282ad6118771f79b38a72fc10ffaa19f0037564d1adb710c7da0b981dad37f9cdf9b6f665cfd
|
|
7
|
+
data.tar.gz: 1b30d461514d2f952e71e3ce7325dd5582fa386ca21723458b725378f6f78880f96bf5693a03aeb64d8a70775830979fe6d8f732c67076abaf9fd687e0ff4948
|
|
@@ -74,13 +74,20 @@ module OpenHAB
|
|
|
74
74
|
# All persistence methods that require a timestamp
|
|
75
75
|
# Note the _between methods are automatically created from the _since methods
|
|
76
76
|
PERSISTENCE_METHODS = (QUANTITY_METHODS +
|
|
77
|
-
%i[changed_since?
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
77
|
+
%i[ changed_since?
|
|
78
|
+
count_since
|
|
79
|
+
count_state_changes_since
|
|
80
|
+
historic_state
|
|
81
|
+
maximum_since
|
|
82
|
+
minimum_since
|
|
83
|
+
updated_since?])
|
|
84
|
+
|
|
85
|
+
# @deprecated OH3.4 - in openHAB 4, just add :get_all_states_since and freeze the list above
|
|
86
|
+
if Gem::Version.new(OpenHAB::Core::VERSION) >= Gem::Version.new("4.0.0")
|
|
87
|
+
PERSISTENCE_METHODS << :get_all_states_since
|
|
88
|
+
end
|
|
89
|
+
PERSISTENCE_METHODS.freeze
|
|
90
|
+
|
|
84
91
|
private_constant :QUANTITY_METHODS, :PERSISTENCE_METHODS
|
|
85
92
|
|
|
86
93
|
# @!method persist(service = nil)
|
|
@@ -275,6 +282,21 @@ module OpenHAB
|
|
|
275
282
|
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
|
276
283
|
# @return [Integer] The number of values persisted for this item.
|
|
277
284
|
|
|
285
|
+
# @!method all_states_since(timestamp, service = nil)
|
|
286
|
+
# @since openHAB 4.0
|
|
287
|
+
# Returns all the states from a point in time until now.
|
|
288
|
+
# @param [#to_zoned_date_time] timestamp The point in time from which to search
|
|
289
|
+
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
|
290
|
+
# @return [Array<HistoricState>] An array of {HistoricState} persisted for this item.
|
|
291
|
+
|
|
292
|
+
# @!method all_states_between(start, finish, service = nil)
|
|
293
|
+
# @since openHAB 4.0
|
|
294
|
+
# Returns all the states between two points in time.
|
|
295
|
+
# @param [#to_zoned_date_time] start The point in time from which to search
|
|
296
|
+
# @param [#to_zoned_date_time] finish The point in time to which to search
|
|
297
|
+
# @param [Symbol, String] service An optional persistence id instead of the default persistence service.
|
|
298
|
+
# @return [Array<HistoricState>] An array of {HistoricState} persisted for this item.
|
|
299
|
+
|
|
278
300
|
%i[persist last_update].each do |method|
|
|
279
301
|
define_method(method) do |service = nil|
|
|
280
302
|
service ||= persistence_service
|
|
@@ -363,6 +385,11 @@ module OpenHAB
|
|
|
363
385
|
|
|
364
386
|
alias_method :state_changes_since, :count_state_changes_since
|
|
365
387
|
alias_method :state_changes_between, :count_state_changes_between
|
|
388
|
+
# @deprecated OH 3.4 - if guard is unnecessary in OH4
|
|
389
|
+
if Gem::Version.new(OpenHAB::Core::VERSION) >= Gem::Version.new("4.0.0")
|
|
390
|
+
alias_method :all_states_since, :get_all_states_since
|
|
391
|
+
alias_method :all_states_between, :get_all_states_between
|
|
392
|
+
end
|
|
366
393
|
|
|
367
394
|
private
|
|
368
395
|
|
|
@@ -391,15 +418,21 @@ module OpenHAB
|
|
|
391
418
|
# @return [HistoricState] a {HistoricState} object if the result was a HistoricItem
|
|
392
419
|
# @return [QuantityType] a `QuantityType` object if the result was an average, delta, deviation,
|
|
393
420
|
# sum, or variance.
|
|
421
|
+
# @return [Array<HistoricState>] an array of {HistoricState} objects if the result was an array
|
|
422
|
+
# of HistoricItem
|
|
394
423
|
# @return [Object] the original result object otherwise.
|
|
395
424
|
#
|
|
396
425
|
def wrap_result(result, method)
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
426
|
+
case result
|
|
427
|
+
when org.openhab.core.persistence.HistoricItem
|
|
428
|
+
HistoricState.new(quantify(result.state), result)
|
|
429
|
+
when java.util.Collection, Array
|
|
430
|
+
result.to_a.map { |historic_item| wrap_result(historic_item, method) }
|
|
431
|
+
else
|
|
432
|
+
return quantify(result) if QUANTITY_METHODS.include?(method)
|
|
401
433
|
|
|
402
|
-
|
|
434
|
+
result
|
|
435
|
+
end
|
|
403
436
|
end
|
|
404
437
|
|
|
405
438
|
#
|
|
@@ -81,7 +81,8 @@ module OpenHAB
|
|
|
81
81
|
def process_active_timer(timer, inputs, mod, &block)
|
|
82
82
|
old_state = Conditions.old_state_from(inputs)
|
|
83
83
|
new_state = Conditions.new_state_from(inputs)
|
|
84
|
-
if new_state != @tracking_from &&
|
|
84
|
+
if @conditions.from? && new_state != @tracking_from &&
|
|
85
|
+
@conditions.process(mod: nil, inputs: { "state" => new_state })
|
|
85
86
|
logger.trace("Item changed from #{old_state} to #{new_state} for #{self}, keep waiting.")
|
|
86
87
|
else
|
|
87
88
|
logger.trace("Item changed from #{old_state} to #{new_state} for #{self}, canceling timer.")
|
data/lib/openhab/dsl/version.rb
CHANGED
data/lib/openhab/log.rb
CHANGED
|
@@ -296,8 +296,8 @@ module OpenHAB
|
|
|
296
296
|
return error if debug?
|
|
297
297
|
|
|
298
298
|
if error.respond_to? :backtrace_locations
|
|
299
|
-
backtrace = error.backtrace_locations
|
|
300
|
-
error.set_backtrace(backtrace)
|
|
299
|
+
backtrace = error.backtrace_locations&.map(&:to_s)&.grep_v(INTERNAL_CALL_REGEX)
|
|
300
|
+
error.set_backtrace(backtrace) if backtrace
|
|
301
301
|
elsif error.respond_to? :stack_trace
|
|
302
302
|
backtrace = error.stack_trace.reject { |line| JAVA_INTERNAL_CALL_REGEX.match? line.to_s }
|
|
303
303
|
error.set_stack_trace(backtrace)
|
|
@@ -229,8 +229,17 @@ module OpenHAB
|
|
|
229
229
|
bundle = org.osgi.framework.FrameworkUtil.get_bundle(org.openhab.core.persistence.PersistenceService.java_class)
|
|
230
230
|
bundle.bundle_context.register_service(org.openhab.core.persistence.PersistenceService.java_class, ps, nil)
|
|
231
231
|
|
|
232
|
-
# wait for the rule engine
|
|
233
232
|
rs = OSGi.service("org.openhab.core.service.ReadyService")
|
|
233
|
+
|
|
234
|
+
# Add a fake automation:scriptEngineFactories to satisfy startlevel 30
|
|
235
|
+
begin
|
|
236
|
+
sef_marker = org.openhab.core.automation.module.script.internal.ScriptEngineFactoryBundleTracker::READY_MARKER
|
|
237
|
+
rs.mark_ready(sef_marker)
|
|
238
|
+
rescue NameError
|
|
239
|
+
# @deprecated OH3.4 NOOP - the ScriptEngineFactoryBundleTracker doesn't exist in OH3
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
# wait for the rule engine
|
|
234
243
|
filter = org.openhab.core.service.ReadyMarkerFilter.new
|
|
235
244
|
.with_type(org.openhab.core.service.StartLevelService::STARTLEVEL_MARKER_TYPE)
|
|
236
245
|
.with_identifier(org.openhab.core.service.StartLevelService::STARTLEVEL_RULEENGINE.to_s)
|
data/lib/openhab/rspec.rb
CHANGED
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.
|
|
4
|
+
version: 5.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brian O'Connell
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2023-
|
|
13
|
+
date: 2023-08-08 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: bundler
|