Group lights with virtual switch - need help with changing the switch state


#1

Hi.

I have alot of HUE bulbs and want to group them togheter with a virtual switch.
That is working fine and I can turn on and off the bulbs with the virtual switch in the ST app. But if I use the HUE app or my physical switch, the state of the virtual switch is not changing and I like to create a piston to help with that.

I created a piston that will turn on all the bulbs and change the state of the virtual switch to on if one single bulb is turned on. That is working.
In the same piston I tried to get the virtual switch to turn off, if all the bulbs in that zone is turned off. But I can manage to get it to work.
Can anyone help me with this?

Log from ST:

bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:21 PM: info β•” Event processed successfully (286ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:21 PM: trace β•‘β•” Execution stage complete. (35ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:21 PM: debug β•‘β•‘ Condition group #5 evaluated false (state did not change) (10ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:21 PM: debug β•‘β•‘ Condition #8 evaluated false (8ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:21 PM: debug β•‘β•‘ Cancelling condition #8’s schedules…
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:21 PM: debug β•‘β•‘ Condition group #1 evaluated false (state did not change) (10ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:21 PM: debug β•‘β•‘ Condition #4 evaluated false (8ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:21 PM: trace β•‘β•š Execution stage started
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:21 PM: trace β•‘ Runtime (36464 bytes) successfully initialized in 34ms (v0.2.0e7.20170906) (242ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:21 PM: debug β•‘ RunTime Analysis CS > 27ms > PS > 34ms > PE > 175ms > CE
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:20 PM: info β•š Received event [Lys - Bad 2].switch = off with a delay of 100ms
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:18 PM: info β•” Event processed successfully (187ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:18 PM: trace β•‘β•” Execution stage complete. (42ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:18 PM: debug β•‘β•‘ Condition #9 evaluated false (11ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:18 PM: debug β•‘β•‘ Condition #8 evaluated true (7ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:18 PM: debug β•‘β•‘ Condition group #5 evaluated false (state did not change) (21ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:18 PM: debug β•‘β•‘ Cancelling condition #8’s schedules…
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:18 PM: debug β•‘β•‘ Comparison (enum) off changes_to (string) off = true (1ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:18 PM: debug β•‘β•‘ Condition #4 evaluated false (6ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:18 PM: debug β•‘β•‘ Condition group #1 evaluated false (state did not change) (8ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:18 PM: debug β•‘β•‘ Comparison (enum) off changes_to (string) on = false (1ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:18 PM: trace β•‘β•š Execution stage started
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:18 PM: trace β•‘ Runtime (36463 bytes) successfully initialized in 38ms (v0.2.0e7.20170906) (136ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:18 PM: debug β•‘ RunTime Analysis CS > 16ms > PS > 38ms > PE > 76ms > CE
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:18 PM: info β•š Received event [Lys - Bad 1].switch = off with a delay of 77ms
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:15 PM: info β•” Event processed successfully (318ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:15 PM: trace β•‘β•” Execution stage complete. (54ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:15 PM: debug β•‘β•‘ Condition group #5 evaluated false (state did not change) (13ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:15 PM: debug β•‘β•‘ Condition #8 evaluated false (10ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:15 PM: debug β•‘β•‘ Condition group #1 evaluated false (state changed) (17ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:15 PM: debug β•‘β•‘ Cancelling condition #1’s schedules…
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:15 PM: debug β•‘β•‘ Condition #4 evaluated false (13ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:15 PM: debug β•‘β•‘ Cancelling condition #4’s schedules…
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:15 PM: trace β•‘β•š Execution stage started
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:15 PM: trace β•‘ Runtime (36461 bytes) successfully initialized in 49ms (v0.2.0e7.20170906) (252ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:15 PM: debug β•‘ RunTime Analysis CS > 37ms > PS > 49ms > PE > 160ms > CE
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:15 PM: info β•š Received event [Lys - Bad 2].switch = on with a delay of 92ms
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:14 PM: trace β•‘β•” Execution stage complete. (365ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:14 PM: debug β•‘β•‘ Condition group #5 evaluated false (state did not change) (7ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:14 PM: debug β•‘β•‘ Executed physical command [Lys - Bad 2].on() (35ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:14 PM: debug β•‘β•‘ Comparison (enum) on changes_to (string) off = false (1ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:14 PM: debug β•‘β•‘ Condition group #1 evaluated true (state changed) (8ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:14 PM: trace β•‘β•‘ Executed [Lys - Bad 2].on (37ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:14 PM: debug β•‘β•‘ Cancelling condition #4’s schedules…
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:14 PM: trace β•‘β•‘ Executed [Lys - Bad].on (294ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:14 PM: debug β•‘β•‘ Condition #4 evaluated true (7ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:14 PM: debug β•‘β•‘ Executed physical command [Lys - Bad].on() (293ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:14 PM: debug β•‘β•‘ Cancelling condition #1’s schedules…
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:14 PM: trace β•‘ Runtime (36462 bytes) successfully initialized in 37ms (v0.2.0e7.20170906) (134ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:14 PM: debug β•‘β•‘ Comparison (enum) on changes_to (string) on = true (1ms)
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:14 PM: trace β•‘β•š Execution stage started
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:14 PM: debug β•‘ RunTime Analysis CS > 14ms > PS > 37ms > PE > 77ms > CE
bfb64913-fc99-47dd-8729-7aeb1c254efb 11:41:14 PM: info β•š Received event [Lys - Bad 1].switch = on with a delay of 67ms


#2

Your second If has 2 triggers. This will not work because they cannot both be true at exactly the same time.

Change it so it reads.

If white bulb 1 & white bulb 2 are both Off.
Then
With xxxx
Do xxxxxxxx

And because it will then have a mix of conditions and triggers don’t forget to subscribe to the second if’s conditions.


#3

Thank you for the quick reply.
It makes sense that they cannot both be true at the same time :slight_smile:

I changed and subscribe to the second if’s, but it still doesn’t change to off for the virtual switch.


#5

Sorry. I’ve just looked at your piston again and you still have is set for 2 triggers to be true at the same time. Change the β€œchanges to” to β€œare” on line 27.


#6

@henlagt here is an example of what I meant.
Try importing this piston using the Backup code and change the devices to match yours.


#7

Ah I missed that. Thank you so much. Now it works :slight_smile:
Appreciate the help!