openhab-scripting 2.22.0 → 2.22.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/openhab/dsl/rules/automation_rule.rb +29 -4
- data/lib/openhab/dsl/rules/triggers/changed.rb +2 -10
- data/lib/openhab/version.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: 854569a4ecda01dc3fb8dc2e12f66147248a2aafffdbbdbabe5d0e750b6849cc
|
4
|
+
data.tar.gz: 1bf8451a6c8d1dd556472ffa0ceb210e34b9db1b0af6a652bdb336182abb7f20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cb862c98031f4d62d1366dbfaf4a9370103687ad06ab930db77dba32af5623337652d9264f09f28622c12b14314902d1a5ea3b58fffec4cfa2fdd086c3bab31
|
7
|
+
data.tar.gz: 2044c8d3cee633c59b9368889c7995b4533b29add5d36e97dc3b8400706229c0afd133121b816fd8b4f53886b86e82b281f9dbe659e104c859bec212f6f5e1d8
|
@@ -100,8 +100,7 @@ module OpenHAB
|
|
100
100
|
# @return [Boolean] True if the rule should execute, false if trigger guard prevents execution
|
101
101
|
#
|
102
102
|
def check_trigger_guards(trigger_delay, inputs)
|
103
|
-
old_state = inputs
|
104
|
-
new_state = inputs['newState']
|
103
|
+
new_state, old_state = retrieve_states(inputs)
|
105
104
|
if check_from(trigger_delay, old_state)
|
106
105
|
return true if check_to(trigger_delay, new_state)
|
107
106
|
|
@@ -113,6 +112,32 @@ module OpenHAB
|
|
113
112
|
end
|
114
113
|
end
|
115
114
|
|
115
|
+
#
|
116
|
+
# Rerieve the newState and oldState, alternatively newStatus and oldStatus
|
117
|
+
# from the input map
|
118
|
+
#
|
119
|
+
# @param [Map] inputs OpenHAB map object describing rule trigger
|
120
|
+
#
|
121
|
+
# @return [Array] An array of the values for [newState, oldState] or [newStatus, oldStatus]
|
122
|
+
#
|
123
|
+
def retrieve_states(inputs)
|
124
|
+
old_state = inputs['oldState'] || thing_status_to_sym(inputs['oldStatus'])
|
125
|
+
new_state = inputs['newState'] || thing_status_to_sym(inputs['newStatus'])
|
126
|
+
|
127
|
+
[new_state, old_state]
|
128
|
+
end
|
129
|
+
|
130
|
+
#
|
131
|
+
# Converts a ThingStatus object to a ruby Symbol
|
132
|
+
#
|
133
|
+
# @param [Java::OrgOpenhabCoreThing::ThingStatus] status A ThingStatus instance
|
134
|
+
#
|
135
|
+
# @return [Symbol] A corresponding symbol, in lower case
|
136
|
+
#
|
137
|
+
def thing_status_to_sym(status)
|
138
|
+
status&.to_s&.downcase&.to_sym
|
139
|
+
end
|
140
|
+
|
116
141
|
#
|
117
142
|
# Check the from state against the trigger delay
|
118
143
|
#
|
@@ -174,7 +199,7 @@ module OpenHAB
|
|
174
199
|
queue = create_queue(inputs)
|
175
200
|
process_queue(queue, mod, inputs)
|
176
201
|
end
|
177
|
-
trigger_delay.tracking_to = inputs
|
202
|
+
trigger_delay.tracking_to, = retrieve_states(inputs)
|
178
203
|
end
|
179
204
|
|
180
205
|
#
|
@@ -186,7 +211,7 @@ module OpenHAB
|
|
186
211
|
#
|
187
212
|
#
|
188
213
|
def process_active_timer(inputs, mod, trigger_delay)
|
189
|
-
state = inputs
|
214
|
+
state, = retrieve_states(inputs)
|
190
215
|
if state == trigger_delay.tracking_to
|
191
216
|
logger.trace("Item changed to #{state} for #{trigger_delay}, rescheduling timer.")
|
192
217
|
trigger_delay.timer.reschedule(ZonedDateTime.now.plus(trigger_delay.duration))
|
@@ -58,16 +58,8 @@ module OpenHAB
|
|
58
58
|
# @return [Array] Array of current TriggerDelay objects
|
59
59
|
#
|
60
60
|
def changed_wait(item, duration:, to: nil, from: nil)
|
61
|
-
|
62
|
-
|
63
|
-
config = { 'groupName' => item.group.name }
|
64
|
-
trigger = Trigger::GROUP_STATE_CHANGE
|
65
|
-
else
|
66
|
-
config = { 'itemName' => item.name }
|
67
|
-
trigger = Trigger::ITEM_STATE_CHANGE
|
68
|
-
end
|
69
|
-
logger.trace("Creating Changed Wait Change Trigger for #{config}")
|
70
|
-
trigger = append_trigger(trigger, config)
|
61
|
+
trigger = create_changed_trigger(item, nil, nil)
|
62
|
+
logger.trace("Creating Changed Wait Change Trigger for #{item}")
|
71
63
|
@trigger_delays[trigger.id] = TriggerDelay.new(to: to, from: from, duration: duration)
|
72
64
|
end
|
73
65
|
|
data/lib/openhab/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openhab-scripting
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.22.
|
4
|
+
version: 2.22.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian O'Connell
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|