1) Give a description of the problem
Trying to determine how to use the $devices
variable in my pistons, to control a group of resources.
2) What is the expected behaviour?
My use case is that I’d like to keep certain groups of devices in sync with each other. In this example, all my basement lights should remain in sync - if one turns on, they should all turn on, and vice versa.
However, I’d like to be able to have multiple groups of devices in one piston, for simplicity’s sake, and have the one piston statement control whichever is triggered. Each group of pistons would be defined as variables, and the “if” statement in the execute block would say “if any device in any of these groups fires”.
3) What is happening/not happening?
I can control a device group if I specify it specifically, but it doesn’t work when using $devices
4) More Info
Non-working example:
9/1/2021, 2:46:54 PM +672ms
+14ms ╔Received event [Downstairs Lights].switch = on with a delay of 31ms, canQueue: true, calledMyself: false
+33ms ║RunTime initialize > 32 LockT > 1ms > rtDT > 17ms > pistonT > 16ms (first state access 14 15 17)
+35ms ║Runtime (6055 bytes) successfully initialized in 17ms (v0.3.113.20210825_HE)
+37ms ║╔Execution stage started
+46ms ║║Comparison (enum) on changes = true (1ms)
+48ms ║║Cancelling condition #2's schedules...
+49ms ║║Condition #2 evaluated true (8ms)
+51ms ║║Cancelling condition #1's schedules...
+52ms ║║Condition group #1 evaluated true (state changed) (11ms)
+53ms ║║Cancelling statement #3's schedules...
+58ms ║║Error reading current value for Hubitat.switch: groovy.lang.MissingMethodException: No signature of method: com.hubitat.hub.domain.Location.currentValue() is applicable for argument types: (java.lang.String, java.lang.Boolean) values: [switch, true]
+310ms ║║Error while executing physical command Hubitat.on([]): groovy.lang.MissingMethodException: No signature of method: com.hubitat.hub.domain.Location.on() is applicable for argument types: () values: [] Possible solutions: any(), is(java.lang.Object), any(groovy.lang.Closure), clone(), find(), use(Ljava.lang.Object;)
+429ms ║║Executed virtual command [Hubitat].setSwitch (372ms)
+435ms ║║Calculating (string)DEBUG: + (string)Empty device list >> (string)DEBUG: Empty device list
+439ms ║║DEBUG: Empty device list
+441ms ║║Executed virtual command log (3ms)
+446ms ║╚Execution stage complete. (410ms)
+449ms ╚Event processed successfully (437ms)
When I run the piston as above, it doesn’t work. However this one does (only diff is line 22):
|+1ms|╔Received event [Downstairs Server Room Lights].switch = on with a delay of 140ms, canQueue: false, calledMyself: true|
|---|---|
|+5ms|║RunTime initialize > 4 LockT > 0ms > rtDT > 1ms > pistonT > 0ms (first state access 3 2 2)|
|+7ms|║Runtime (6110 bytes) successfully initialized in 1ms (v0.3.113.20210825_HE)|
|+8ms|║╔Execution stage started|
|+21ms|║║Comparison (enum) on changes = true (1ms)|
|+23ms|║║Condition #2 evaluated true (12ms)|
|+24ms|║║Condition group #1 evaluated true (state did not change) (14ms)|
|+26ms|║║Cancelling statement #3's schedules...|
|+32ms|║║Skipped execution of physical command [Downstairs Lights].on([]) because it would make no change to the device. (1ms)|
|+33ms|║║Executed virtual command [Downstairs Lights].setSwitch (2ms)|
|+37ms|║║Skipped execution of physical command [Downstairs Server Room Lights].on([]) because it would make no change to the device. (1ms)|
|+38ms|║║Executed virtual command [Downstairs Server Room Lights].setSwitch (1ms)|
|+42ms|║║Skipped execution of physical command [Downstairs Stair Lights].on([]) because it would make no change to the device. (1ms)|
|+43ms|║║Executed virtual command [Downstairs Stair Lights].setSwitch (2ms)|
|+49ms|║║Calculating (string)DEBUG: + (string)Downstairs Lights, Downstairs Server Room Lights and Downstairs Stair Lights >> (string)DEBUG: Downstairs Lights, Downstairs Server Room Lights and Downstairs Stair Lights|
|+55ms|║║DEBUG: Downstairs Lights, Downstairs Server Room Lights and Downstairs Stair Lights|
|+57ms|║║Executed virtual command [Downstairs Lights, Downstairs Server Room Lights, Downstairs Stair Lights].log (3ms)|
|+62ms|║╚Execution stage complete. (54ms)|
|+65ms|╚Event processed successfully (64ms)|
Notice that in the “not working” piston, the DEBUG output I added shows “Empty Device List”, while the “working” piston has a valid list of devices. Why is it not populating in the nonworking example, and how can I (or can I at all?) make this work?