openhab-scripting 2.23.1 → 2.23.2
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/dsl/monkey_patch/events/events.rb +1 -0
- data/lib/openhab/dsl/monkey_patch/events/item_event.rb +28 -0
- data/lib/openhab/dsl/monkey_patch/events/item_state_changed.rb +0 -11
- data/lib/openhab/dsl/rules/automation_rule.rb +4 -20
- data/lib/openhab/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ee0da4d4273752f4a2e7b0239c09f379f74acbc05edc3f3d10690a923c3d90a
|
4
|
+
data.tar.gz: b807d26604402500b68ebbfc5b4a5afe6a4c65c963a3d1a3f625a703957239f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9770cad933c03a36f70d320b04e43d9f9394e15da250a1be849a1669a7a863371cac83774d48f76f3dd44c97176b5ccac180f62167adf13c0b316ab431ee41e
|
7
|
+
data.tar.gz: add9dc156271bbec0918744355bf1362e387f3ce4792be28470abc57c03fd0a7e83acf69798bddfb8f142841dd202fa8df65bbb6c85f222bb8f58302f1686062
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'openhab/dsl/monkey_patch/events/item_state'
|
4
|
+
require 'openhab/dsl/monkey_patch/events/item_event'
|
4
5
|
require 'openhab/dsl/monkey_patch/events/item_state_changed'
|
5
6
|
require 'openhab/dsl/monkey_patch/events/thing_status_info'
|
6
7
|
require 'openhab/dsl/monkey_patch/events/item_command'
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'java'
|
4
|
+
|
5
|
+
module OpenHAB
|
6
|
+
module DSL
|
7
|
+
module MonkeyPatch
|
8
|
+
#
|
9
|
+
# Patches OpenHAB events
|
10
|
+
#
|
11
|
+
module Events
|
12
|
+
java_import Java::OrgOpenhabCoreItemsEvents::ItemEvent
|
13
|
+
|
14
|
+
#
|
15
|
+
# MonkeyPatch to add item
|
16
|
+
#
|
17
|
+
class ItemEvent
|
18
|
+
#
|
19
|
+
# Return a decorated item
|
20
|
+
#
|
21
|
+
def item
|
22
|
+
OpenHAB::Core::EntityLookup.lookup_item(item_name)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -15,17 +15,6 @@ module OpenHAB
|
|
15
15
|
# MonkeyPatch with ruby style accessors
|
16
16
|
#
|
17
17
|
class ItemStateChangedEvent
|
18
|
-
#
|
19
|
-
# Get the item that caused the state change
|
20
|
-
#
|
21
|
-
# @return [Item] Item that caused state change
|
22
|
-
#
|
23
|
-
def item
|
24
|
-
# rubocop:disable Style/GlobalVars
|
25
|
-
$ir.get(item_name)
|
26
|
-
# rubocop:enable Style/GlobalVars
|
27
|
-
end
|
28
|
-
|
29
18
|
alias state item_state
|
30
19
|
alias last old_item_state
|
31
20
|
end
|
@@ -243,21 +243,6 @@ module OpenHAB
|
|
243
243
|
false
|
244
244
|
end
|
245
245
|
|
246
|
-
#
|
247
|
-
# Patch event to decorate event.item with our item wrapper
|
248
|
-
#
|
249
|
-
# @param [OpenHAB Event] event patch
|
250
|
-
#
|
251
|
-
def decorate_event_item(event)
|
252
|
-
return if event.nil?
|
253
|
-
|
254
|
-
class << event
|
255
|
-
def item
|
256
|
-
OpenHAB::Core::EntityLookup.lookup_item(item_name)
|
257
|
-
end
|
258
|
-
end
|
259
|
-
end
|
260
|
-
|
261
246
|
#
|
262
247
|
# Process the run queue
|
263
248
|
#
|
@@ -287,7 +272,6 @@ module OpenHAB
|
|
287
272
|
#
|
288
273
|
#
|
289
274
|
def process_otherwise_task(event, task)
|
290
|
-
decorate_event_item(event)
|
291
275
|
logger.trace { "Executing rule '#{name}' otherwise block with event(#{event})" }
|
292
276
|
task.block.call(event)
|
293
277
|
end
|
@@ -314,9 +298,10 @@ module OpenHAB
|
|
314
298
|
#
|
315
299
|
#
|
316
300
|
def process_trigger_task(event, task)
|
317
|
-
|
318
|
-
|
319
|
-
|
301
|
+
return unless event&.item
|
302
|
+
|
303
|
+
logger.trace { "Executing rule '#{name}' trigger block with item (#{event.item})" }
|
304
|
+
task.block.call(event.item)
|
320
305
|
end
|
321
306
|
|
322
307
|
#
|
@@ -327,7 +312,6 @@ module OpenHAB
|
|
327
312
|
#
|
328
313
|
#
|
329
314
|
def process_run_task(event, task)
|
330
|
-
decorate_event_item(event)
|
331
315
|
logger.trace { "Executing rule '#{name}' run block with event(#{event})" }
|
332
316
|
task.block.call(event)
|
333
317
|
end
|
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.23.
|
4
|
+
version: 2.23.2
|
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-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -50,6 +50,7 @@ files:
|
|
50
50
|
- lib/openhab/dsl/monkey_patch/actions/script_thing_actions.rb
|
51
51
|
- lib/openhab/dsl/monkey_patch/events/events.rb
|
52
52
|
- lib/openhab/dsl/monkey_patch/events/item_command.rb
|
53
|
+
- lib/openhab/dsl/monkey_patch/events/item_event.rb
|
53
54
|
- lib/openhab/dsl/monkey_patch/events/item_state.rb
|
54
55
|
- lib/openhab/dsl/monkey_patch/events/item_state_changed.rb
|
55
56
|
- lib/openhab/dsl/monkey_patch/events/thing_status_info.rb
|