Device list not updating correct on an IF pickup list


#1

1) Give a description of the problem
I am using the IF feature the pick which device is ON and which is OFF. The OFF list updates but not for the ON list.

2) What is the expected behaviour?

that the ON list should update also

3) What is happening/not happening?

The OFF list is updating and also including the the device that is on. And the ON is not updating and is always empty.

4) Post a Green Snapshot of the pistonimage

5) Attach logs after turning logging level to Full
(PASTE YOUR LOGS HERE THEN HIGHLIGHT ALL OF THE LOGS AND CLICK ON THE </> ICON TO FORMAT THEM CORRECTLY)

6/30/2021, 12:15:10 PM +454ms
+6ms ╔Received event [virtual-Echo-Victor].switch = off with a delay of 56ms, canQueue: true, calledMyself: false
+15ms ║RunTime initialize > 14 LockT > 1ms > rtDT > 2ms > pistonT > 1ms (first state access 11 7 7)
+20ms ║Runtime (13088 bytes) successfully initialized in 2ms (v0.3.113.20210510_HE)
+21ms ║╔Execution stage started
+33ms ║║Condition #2 evaluated false (9ms)
+35ms ║║Condition group #1 evaluated false (state did not change) (10ms)
+44ms ║║Comparison (enum) off changes_to (string) on = false (0ms)
+48ms ║║Cancelling condition #34’s schedules…
+50ms ║║Condition #34 evaluated false (12ms)
+51ms ║║Cancelling condition #33’s schedules…
+53ms ║║Condition group #33 evaluated false (state changed) (16ms)
+56ms ║╚Execution stage complete. (36ms)
+59ms ╚Event processed successfully (55ms)
6/30/2021, 12:15:10 PM +296ms
+6ms ╔Received event [virtual-Echo-Nathalia].switch = on with a delay of 60ms, canQueue: true, calledMyself: false
+15ms ║RunTime initialize > 14 LockT > 1ms > rtDT > 2ms > pistonT > 1ms (first state access 11 7 7)
+20ms ║Runtime (13084 bytes) successfully initialized in 2ms (v0.3.113.20210510_HE)
+21ms ║╔Execution stage started
+60ms ║║Condition #2 evaluated false (36ms)
+62ms ║║Condition group #1 evaluated false (state did not change) (38ms)
+71ms ║║Comparison (enum) on changes_to (string) on = true (0ms)
+76ms ║║Condition #34 evaluated true (12ms)
+78ms ║║Condition group #33 evaluated true (state did not change) (14ms)
+79ms ║║Cancelling statement #35’s schedules…
+84ms ║║Skipped execution of physical command [virtual-Echo-Studio].off([]) because it would make no change to the device. (1ms)
+85ms ║║Executed [virtual-Echo-Studio].off (3ms)
+89ms ║║Skipped execution of physical command [virtual-Echo-Suite].off([]) because it would make no change to the device. (1ms)
+90ms ║║Executed [virtual-Echo-Suite].off (3ms)
+93ms ║║Skipped execution of physical command [virtual-Echo-TodoLugar].off([]) because it would make no change to the device. (1ms)
+94ms ║║Executed [virtual-Echo-TodoLugar].off (3ms)
+106ms ║║Executed physical command [virtual-Echo-Victor].off() (9ms)
+107ms ║║Executed [virtual-Echo-Victor].off (12ms)
+113ms ║╚Execution stage complete. (92ms)
+116ms ╚Event processed successfully (111ms)
6/30/2021, 12:14:18 PM +85ms
+6ms ╔Received event [virtual-Echo-Victor].switch = on with a delay of 84ms, canQueue: true, calledMyself: false
+16ms ║RunTime initialize > 15 LockT > 1ms > rtDT > 2ms > pistonT > 1ms (first state access 12 8 7)
+20ms ║Runtime (13080 bytes) successfully initialized in 2ms (v0.3.113.20210510_HE)
+22ms ║╔Execution stage started
+33ms ║║Cancelling condition #2’s schedules…
+34ms ║║Condition #2 evaluated false (9ms)
+36ms ║║Cancelling condition #1’s schedules…
+37ms ║║Condition group #1 evaluated false (state changed) (12ms)
+47ms ║║Comparison (enum) on changes_to (string) on = true (1ms)
+51ms ║║Cancelling condition #34’s schedules…
+53ms ║║Condition #34 evaluated true (13ms)
+54ms ║║Cancelling condition #33’s schedules…
+56ms ║║Condition group #33 evaluated true (state changed) (16ms)
+57ms ║║Cancelling statement #35’s schedules…
+62ms ║║Skipped execution of physical command [virtual-Echo-Nathalia].off([]) because it would make no change to the device. (1ms)
+64ms ║║Executed [virtual-Echo-Nathalia].off (4ms)
+67ms ║║Skipped execution of physical command [virtual-Echo-Studio].off([]) because it would make no change to the device. (1ms)
+68ms ║║Executed [virtual-Echo-Studio].off (3ms)
+71ms ║║Skipped execution of physical command [virtual-Echo-Suite].off([]) because it would make no change to the device. (1ms)
+74ms ║║Executed [virtual-Echo-Suite].off (4ms)
+77ms ║║Skipped execution of physical command [virtual-Echo-TodoLugar].off([]) because it would make no change to the device. (2ms)
+78ms ║║Executed [virtual-Echo-TodoLugar].off (3ms)
+83ms ║╚Execution stage complete. (61ms)
+85ms ╚Event processed successfully (81ms)
6/30/2021, 12:13:43 PM +557ms
+6ms ╔Received event [Playlist Casa].switch = on with a delay of 61ms, canQueue: true, calledMyself: false
+15ms ║RunTime initialize > 14 LockT > 1ms > rtDT > 2ms > pistonT > 1ms (first state access 11 7 7)
+20ms ║Runtime (13071 bytes) successfully initialized in 2ms (v0.3.113.20210510_HE)
+21ms ║╔Execution stage started
+32ms ║║Comparison (enum) on changes_to (string) on = true (0ms)
+38ms ║║Condition #2 evaluated true (13ms)
+39ms ║║Condition group #1 evaluated true (state did not change) (14ms)
+44ms ║║Comparison (enum) off is (string) on = false (1ms)
+46ms ║║Condition #4 evaluated false (5ms)
+47ms ║║Condition group #3 evaluated false (state did not change) (7ms)
+53ms ║║Comparison (enum) off is (string) on = false (2ms)
+55ms ║║Condition #10 evaluated false (5ms)
+57ms ║║Condition group #9 evaluated false (state did not change) (7ms)
+63ms ║║Comparison (enum) off is (string) on = false (1ms)
+65ms ║║Condition #16 evaluated false (5ms)
+67ms ║║Condition group #15 evaluated false (state did not change) (8ms)
+73ms ║║Comparison (enum) off is (string) on = false (1ms)
+74ms ║║Condition #22 evaluated false (6ms)
+76ms ║║Condition group #21 evaluated false (state did not change) (7ms)
+82ms ║║Comparison (enum) off is (string) on = false (1ms)
+83ms ║║Condition #28 evaluated false (6ms)
+85ms ║║Condition group #27 evaluated false (state did not change) (7ms)
+97ms ║║Condition #34 evaluated false (9ms)
+99ms ║║Condition group #33 evaluated false (state did not change) (11ms)
+103ms ║╚Execution stage complete. (81ms)
+106ms ╚Event processed successfully (102ms)
6/30/2021, 12:13:06 PM +641ms
+6ms ╔Received event [Playlist Academia].switch = on with a delay of 54ms, canQueue: true, calledMyself: false
+68ms ║RunTime initialize > 67 LockT > 1ms > rtDT > 57ms > pistonT > 56ms (first state access 9 7 60)
+73ms ║Runtime (13005 bytes) successfully initialized in 57ms (v0.3.113.20210510_HE)
+74ms ║╔Execution stage started
+92ms ║║Comparison (enum) on changes_to (string) on = true (3ms)
+97ms ║║Cancelling condition #2’s schedules…
+99ms ║║Condition #2 evaluated true (21ms)
+101ms ║║Cancelling condition #1’s schedules…
+102ms ║║Condition group #1 evaluated true (state changed) (24ms)
+110ms ║║Comparison (enum) off is (string) on = false (2ms)
+112ms ║║Condition #4 evaluated false (8ms)
+114ms ║║Condition group #3 evaluated false (state did not change) (10ms)
+123ms ║║Comparison (enum) off is (string) on = false (1ms)
+125ms ║║Condition #10 evaluated false (8ms)
+127ms ║║Condition group #9 evaluated false (state did not change) (10ms)
+136ms ║║Comparison (enum) off is (string) on = false (1ms)
+138ms ║║Condition #16 evaluated false (8ms)
+140ms ║║Condition group #15 evaluated false (state did not change) (11ms)
+149ms ║║Comparison (enum) off is (string) on = false (1ms)
+151ms ║║Condition #22 evaluated false (9ms)
+153ms ║║Condition group #21 evaluated false (state did not change) (11ms)
+162ms ║║Comparison (enum) off is (string) on = false (1ms)
+164ms ║║Condition #28 evaluated false (9ms)
+166ms ║║Condition group #27 evaluated false (state did not change) (11ms)
+180ms ║║Condition #34 evaluated false (11ms)
+220ms ║║Condition group #33 evaluated false (state did not change) (51ms)
+225ms ║╚Execution stage complete. (150ms)
+228ms ╚Event processed successfully (223ms)

REMOVE BELOW AFTER READING
If a solution is found for your question then please mark the post as the solution.


#2

Post the green snapshot with Trace enabled, it’ll make it easier for whoever wants to follow the logs.

image


#3

here it comes


#4

Can you clarify what the problem is?

The logs seem to show two different playlist switches being turned on but all of the virtual echoes being switched off at the time so there not being anything to do.

They then show virtual Victor being having been turned on and nothing needing to done as the other four are off already. Then virtual Nathalia is turned on and Victor is turned off. Then the off event for Victor comes along so there is nothing to do.

I don’t fully understand the logic but I’d have thought the possibility of no virtual echo switches being on needs to be allowed for.


#5

sure.

So, the intention is to create a “selector” so when a switch is on the others are off. also the one that is on can be used to do things with it. So I can use the switch {PlaylistON} and the {EchoON} to make the correspondent Echo device to search the Playlist selected.

The problem is that when I select the correspondent Echo or the correspondent Playlist (they were off at start), the IF doesnt put their names on the ON list. in the end they put everything together on the OFF list.

By the way, I use the virtual switches to use that on a Dashboard. And I need to select from wich Echo device I want to that list to be played since I have more than one Echo device.


#6

The piston is going to run whenever one of the eight switches in searchMusic and Echo generates an on or off event.

If the piston is running because one of the switches in searchMusic has changed from off to on, the trigger condition at lines 27-29 will set Playing to that device, and notPlaying to the other two switches. If the piston is running for any other reason Playing will be empty, and notPlaying will be all the switches in searchMusic.

‘Any other reason’ means: a switch in searchMusic reporting off or reporting on when it was already on; a switch in Echo reporting either on or off; sundry other reasons including using the Test button.

If the piston is running because one of the switches in Echo has changed from off to on, then the trigger condition at lines 103-105 will set EchoON to that switch, and EchoOFF to the other four (the logs show that has happened as the piston only tries to turn off the other four switches). If the piston is running for any other reason EchoON will be empty, and EchoOFF will include all five switches.

‘Any other reason’ means: a switch in Echo reporting off or reporting on when it was already on; a switch in searchMusic reporting either on or off; sundry other reasons including using the Test button.


#7

So, that means that the intention I am trying to archieve above is not possible? What do you suggest? Separate the piston into two?

I disabled the log part and stayed with the last part.
Look what is funny, the logic behind the selector - “turn this on and the rest OFF” works. I turn a switch the other goes off. But on the list related to the OFF, even the one that is ON goes there.

6/30/2021, 4:23:45 PM +19ms
+5ms ╔Received event [virtual-Echo-Studio].switch = off with a delay of 98ms, canQueue: true, calledMyself: false
+15ms ║RunTime initialize > 14 LockT > 1ms > rtDT > 2ms > pistonT > 1ms (first state access 11 7 7)
+19ms ║Runtime (11826 bytes) successfully initialized in 2ms (v0.3.113.20210510_HE)
+20ms ║╔Execution stage started
+30ms ║║Comparison (enum) off changes_to (string) on = false (0ms)
+34ms ║║Cancelling condition #34’s schedules…
+36ms ║║Condition #34 evaluated false (13ms)
+37ms ║║Cancelling condition #33’s schedules…
+39ms ║║Condition group #33 evaluated false (state changed) (16ms)
+43ms ║╚Execution stage complete. (23ms)
+46ms ╚Event processed successfully (41ms)
6/30/2021, 4:23:44 PM +871ms
+6ms ╔Received event [virtual-Echo-Nathalia].switch = on with a delay of 68ms, canQueue: true, calledMyself: false
+15ms ║RunTime initialize > 14 LockT > 1ms > rtDT > 2ms > pistonT > 1ms (first state access 11 7 7)
+18ms ║Runtime (11831 bytes) successfully initialized in 2ms (v0.3.113.20210510_HE)
+20ms ║╔Execution stage started
+29ms ║║Comparison (enum) on changes_to (string) on = true (0ms)
+34ms ║║Cancelling condition #34’s schedules…
+36ms ║║Condition #34 evaluated true (13ms)
+37ms ║║Cancelling condition #33’s schedules…
+39ms ║║Condition group #33 evaluated true (state changed) (16ms)
+41ms ║║Cancelling statement #35’s schedules…
+55ms ║║Executed physical command [virtual-Echo-Studio].off() (11ms)
+57ms ║║Executed [virtual-Echo-Studio].off (13ms)
+61ms ║║Skipped execution of physical command [virtual-Echo-Suite].off([]) because it would make no change to the device. (1ms)
+62ms ║║Executed [virtual-Echo-Suite].off (4ms)
+65ms ║║Skipped execution of physical command [virtual-Echo-TodoLugar].off([]) because it would make no change to the device. (1ms)
+66ms ║║Executed [virtual-Echo-TodoLugar].off (2ms)
+69ms ║║Skipped execution of physical command [virtual-Echo-Victor].off([]) because it would make no change to the device. (1ms)
+71ms ║║Executed [virtual-Echo-Victor].off (3ms)
+75ms ║╚Execution stage complete. (55ms)
+78ms ╚Event processed successfully (73ms)
6/30/2021, 4:23:38 PM +768ms
+5ms ╔Received event [virtual-Echo-Nathalia].switch = off with a delay of 65ms, canQueue: true, calledMyself: false
+14ms ║RunTime initialize > 13 LockT > 1ms > rtDT > 2ms > pistonT > 1ms (first state access 10 6 7)
+18ms ║Runtime (11818 bytes) successfully initialized in 2ms (v0.3.113.20210510_HE)
+19ms ║╔Execution stage started
+30ms ║║Comparison (enum) off changes_to (string) on = false (1ms)
+34ms ║║Cancelling condition #34’s schedules…
+35ms ║║Condition #34 evaluated false (13ms)
+37ms ║║Cancelling condition #33’s schedules…
+38ms ║║Condition group #33 evaluated false (state changed) (17ms)
+42ms ║╚Execution stage complete. (23ms)
+45ms ╚Event processed successfully (41ms)
6/30/2021, 4:23:38 PM +649ms
+6ms ╔Received event [virtual-Echo-Studio].switch = on with a delay of 68ms, canQueue: true, calledMyself: false
+14ms ║RunTime initialize > 13 LockT > 1ms > rtDT > 1ms > pistonT > 1ms (first state access 11 7 6)
+17ms ║Runtime (11785 bytes) successfully initialized in 1ms (v0.3.113.20210510_HE)
+19ms ║╔Execution stage started
+29ms ║║Comparison (enum) on changes_to (string) on = true (0ms)
+34ms ║║Cancelling condition #34’s schedules…
+36ms ║║Condition #34 evaluated true (14ms)
+37ms ║║Cancelling condition #33’s schedules…
+39ms ║║Condition group #33 evaluated true (state changed) (17ms)
+41ms ║║Cancelling statement #35’s schedules…
+59ms ║║Executed physical command [virtual-Echo-Nathalia].off() (15ms)
+60ms ║║Executed [virtual-Echo-Nathalia].off (17ms)
+64ms ║║Skipped execution of physical command [virtual-Echo-Suite].off([]) because it would make no change to the device. (1ms)
+65ms ║║Executed [virtual-Echo-Suite].off (4ms)
+69ms ║║Skipped execution of physical command [virtual-Echo-TodoLugar].off([]) because it would make no change to the device. (1ms)
+70ms ║║Executed [virtual-Echo-TodoLugar].off (3ms)
+73ms ║║Skipped execution of physical command [virtual-Echo-Victor].off([]) because it would make no change to the device. (1ms)
+75ms ║║Executed [virtual-Echo-Victor].off (3ms)
+79ms ║╚Execution stage complete. (60ms)
+82ms ╚Event processed successfully (77ms)


#8

But when are you looking at the OFF?

  1. Lets assume Victor is already turned on and the others are off.
  2. Now let’s turn Nathalia on.
  3. The piston will receive the on event from Nathalia, which would show in the logs as [virtual-Echo-Nathalia].switch = on.
  4. The piston will run and when it reaches lines 27-29 it will return true, putting Nathalia in EchoON and the other four in EchoOFF. The piston will then turn off those four switches. Three are already off and so the piston won’t send a command, but Victor will be turned off.
  5. The piston will receive the off event from Victor, which would show in the logs as [virtual-Echo-Victor].switch = off.
  6. The piston will run again and when it reaches lines 27-29 it will return false, emptying EchoON and putting all five devices in EchoOFF.

So if you turn an Echo switch on and look at the value of the lists a second later, the lists will show all the devices in EchoOFF.

You could simply change from the trigger changes to on to the condition is on so the variables reflect the current state of the switches. The piston will still fire at the same times but will basically do the same thing twice.


#9

If I put IS instead of CHANGES TO the old device will remain on the list like the following:


#10

Ah, yes, sorry I was getting confused there.

You might need to do both.

First use the if ... changes to on to generate the list of switches that needs to be turned off.

Then do if ... is on if you want lists with the current state in. I’d use different lists.


#11

:slight_smile:

now I got confused. Can you giveme a tiny example on what you mean?


#12

Well if we start with your piston shown above (code kmn8), the variables EchoON and EchoOFF are being set on whatever caused the piston to run. So you can keep that, that works for turning the switches off to get them in sync. However it sounds like you want to be able to work with actual state of the switches and that may well be something different. So if after line 36 you add something like

if Any of {Echo}'s switches are on
  save matching devices to {echoINUSE}
  save non-matching devices to {echoNOTINUSE}
then
  ...
end if

you will then have variables to handle that.