Help with WHILE statement or more efficient code


#1

1) Give a description of the problem
While statement seems to work correctly if I execute a separate piston changing the simulated testbulb color from red to white. SHM initiates the color change and piston works but WHILE statement seems to not catch changes when SHM changes RGB light to different color.

2) What is the expected behavior?
Piston waits for trigger of simulated RGB testbulb to change switch to ON. When SHM changes simulated testbulb to Red (which also turns switch on) the piston starts, initiates media players throughout home. Piston loops checking the simulated RGB testbulb for color change. When SHM changes simulated RGB testbulb to any other color (typically white) piston then should stop checking, stop media players and turn off simulated RGB testbulb light.

3) What is happening/not happening?
Piston begins but doesn’t see the color change from red and doesn’t stop.

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)

WebCoRE Logs (IDE LOGS BELOW TOO):

2/21/2018, 7:51:25 AM +144ms
+1ms	╔Starting piston... (v0.2.102.20180116)
+193ms	║╔Subscribing to devices...
+209ms	║║Subscribing to TestLight.switch...
+347ms	║║Subscribing to Dining Room...
+348ms	║║Subscribing to Master Bedroom...
+349ms	║║Subscribing to Room...
+350ms	║╚Finished subscribing (162ms)
+400ms	║Comparison (boolean) false is (boolean) true = false (1ms)
+410ms	║Comparison (boolean) false is (boolean) false = true (1ms)
+427ms	╚Piston successfully started (426ms)
2/20/2018, 9:41:12 PM +883ms
+105ms	╔Stopping piston...
+219ms	╚Piston successfully stopped (114ms)
2/20/2018, 9:08:49 PM +900ms
+1ms	╔Received event [TestLight].switch = off with a delay of 77ms
+224ms	║RunTime Analysis CS > 16ms > PS > 23ms > PE > 185ms > CE
+227ms	║Runtime (42410 bytes) successfully initialized in 23ms (v0.2.102.20180116) (225ms)
+228ms	║╔Execution stage started
+234ms	║║Comparison (enum) off changes_to (string) on = false (0ms)
+236ms	║║Cancelling condition #22's schedules...
+236ms	║║Condition #22 evaluated false (4ms)
+237ms	║║Cancelling condition #21's schedules...
+238ms	║║Condition group #21 evaluated false (state changed) (7ms)
+240ms	║║Cancelling statement #18's schedules...
+243ms	║║Skipped execution of physical command [null].off([]) because it would make no change to the device. (0ms)
+244ms	║║Executed [TestLight].off (2ms)
+246ms	║║Cancelling statement #23's schedules...
+301ms	║║Executed physical command [Dining Room].stop() (50ms)
+301ms	║║Executed [Dining Room].stop (52ms)
+327ms	║║Executed physical command [Master Bedroom].stop() (23ms)
+328ms	║║Executed [Master Bedroom].stop (23ms)
+357ms	║║Executed physical command [Room].stop() (27ms)
+358ms	║║Executed [Room].stop (28ms)
+360ms	║╚Execution stage complete. (133ms)
+361ms	╚Event processed successfully (361ms)
2/20/2018, 9:08:39 PM +832ms
+2ms	╔Received event [TestLight].switch = on with a delay of 107ms
+126ms	║RunTime Analysis CS > 23ms > PS > 23ms > PE > 80ms > CE
+128ms	║Runtime (42112 bytes) successfully initialized in 23ms (v0.2.102.20180116) (126ms)
+129ms	║╔Execution stage started
+136ms	║║Comparison (enum) on changes_to (string) on = true (1ms)
+137ms	║║Cancelling condition #22's schedules...
+137ms	║║Condition #22 evaluated true (4ms)
+138ms	║║Cancelling condition #21's schedules...
+139ms	║║Condition group #21 evaluated true (state changed) (6ms)
+141ms	║║Cancelling statement #14's schedules...
+151ms	║║Executed virtual command [TestLight].setVariable (3ms)
+153ms	║║Cancelling statement #30's schedules...
+160ms	║║Executed virtual command setVariable (3ms)
+162ms	║║Cancelling statement #4's schedules...
+302ms	║║Executed physical command [Dining Room].setLevel([20]) (135ms)
+303ms	║║Executed [Dining Room].setLevel (136ms)
+338ms	║║Executed physical command [Master Bedroom].setLevel([20]) (33ms)
+339ms	║║Executed [Master Bedroom].setLevel (34ms)
+418ms	║║Executed physical command [Room].setLevel([20]) (76ms)
+418ms	║║Executed [Room].setLevel (77ms)
+421ms	║║Cancelling statement #1's schedules...
+462ms	║║Executed physical command [Dining Room].setTrack([http://media/tng.mp3]) (38ms)
+463ms	║║Executed [Dining Room].setTrack (39ms)
+480ms	║║Executed physical command [Master Bedroom].setTrack([http://media/tng.mp3]) (16ms)
+481ms	║║Executed [Master Bedroom].setTrack (18ms)
+498ms	║║Executed physical command [Room].setTrack([http://media/tng.mp3]) (16ms)
+498ms	║║Executed [Room].setTrack (17ms)
+536ms	║║Executed physical command [Dining Room].play() (36ms)
+537ms	║║Executed [Dining Room].play (38ms)
+554ms	║║Executed physical command [Master Bedroom].play() (16ms)
+554ms	║║Executed [Master Bedroom].play (16ms)
+570ms	║║Executed physical command [Room].play() (15ms)
+571ms	║║Executed [Room].play (16ms)
+576ms	║║Comparison (boolean) false is (boolean) true = false (1ms)
+578ms	║║Condition #27 evaluated false (4ms)
+578ms	║║Condition group #26 evaluated false (state did not change) (5ms)
+581ms	║╚Execution stage complete. (451ms)
+582ms	╚Event processed successfully (581ms)
2/20/2018, 9:08:33 PM +869ms
+1ms	╔Received event [TestLight].switch = off with a delay of 61ms
+108ms	║RunTime Analysis CS > 12ms > PS > 15ms > PE > 80ms > CE
+110ms	║Runtime (42109 bytes) successfully initialized in 15ms (v0.2.102.20180116) (108ms)
+111ms	║╔Execution stage started
+117ms	║║Comparison (enum) off changes_to (string) on = false (0ms)
+118ms	║║Cancelling condition #22's schedules...
+119ms	║║Condition #22 evaluated false (4ms)
+120ms	║║Cancelling condition #21's schedules...
+120ms	║║Condition group #21 evaluated false (state changed) (5ms)
+122ms	║║Cancelling statement #18's schedules...
+125ms	║║Skipped execution of physical command [null].off([]) because it would make no change to the device. (0ms)
+126ms	║║Executed [TestLight].off (2ms)
+128ms	║║Cancelling statement #23's schedules...
+166ms	║║Executed physical command [Dining Room].stop() (35ms)
+167ms	║║Executed [Dining Room].stop (37ms)
+184ms	║║Executed physical command [Master Bedroom].stop() (15ms)
+184ms	║║Executed [Master Bedroom].stop (16ms)
+200ms	║║Executed physical command [Room].stop() (12ms)
+200ms	║║Executed [Room].stop (14ms)
+202ms	║╚Execution stage complete. (91ms)
+203ms	╚Event processed successfully (203ms)
2/20/2018, 9:08:18 PM +507ms
+1ms	╔Received event [TestLight].switch = on with a delay of 69ms
+117ms	║RunTime Analysis CS > 20ms > PS > 15ms > PE > 81ms > CE
+119ms	║Runtime (42111 bytes) successfully initialized in 15ms (v0.2.102.20180116) (118ms)
+120ms	║╔Execution stage started
+127ms	║║Comparison (enum) on changes_to (string) on = true (0ms)
+128ms	║║Cancelling condition #22's schedules...
+128ms	║║Condition #22 evaluated true (4ms)
+129ms	║║Cancelling condition #21's schedules...
+130ms	║║Condition group #21 evaluated true (state changed) (6ms)
+132ms	║║Cancelling statement #14's schedules...
+139ms	║║Executed virtual command [TestLight].setVariable (2ms)
+141ms	║║Cancelling statement #30's schedules...
+146ms	║║Executed virtual command setVariable (1ms)
+148ms	║║Cancelling statement #4's schedules...
+230ms	║║Executed physical command [Dining Room].setLevel([20]) (78ms)
+231ms	║║Executed [Dining Room].setLevel (79ms)
+257ms	║║Executed physical command [Master Bedroom].setLevel([20]) (24ms)
+257ms	║║Executed [Master Bedroom].setLevel (24ms)
+316ms	║║Executed physical command [Room].setLevel([20]) (57ms)
+317ms	║║Executed [Room].setLevel (58ms)
+319ms	║║Cancelling statement #1's schedules...
+352ms	║║Executed physical command [Dining Room].setTrack([http://media/tng.mp3]) (30ms)
+353ms	║║Executed [Dining Room].setTrack (31ms)
+365ms	║║Executed physical command [Master Bedroom].setTrack([http://media/tng.mp3]) (11ms)
+366ms	║║Executed [Master Bedroom].setTrack (13ms)
+378ms	║║Executed physical command [Room].setTrack([http://media/tng.mp3]) (11ms)
+379ms	║║Executed [Room].setTrack (12ms)
+409ms	║║Executed physical command [Dining Room].play() (28ms)
+409ms	║║Executed [Dining Room].play (29ms)
+421ms	║║Executed physical command [Master Bedroom].play() (11ms)
+422ms	║║Executed [Master Bedroom].play (12ms)
+433ms	║║Executed physical command [Room].play() (10ms)
+434ms	║║Executed [Room].play (12ms)
+439ms	║║Comparison (boolean) false is (boolean) true = false (1ms)
+440ms	║║Condition #27 evaluated false (4ms)
+441ms	║║Condition group #26 evaluated false (state did not change) (4ms)
+443ms	║╚Execution stage complete. (322ms)
+443ms	╚Event processed successfully (443ms)

GraphIDE Logs:


#2

All looks a bit complicated to me…

Why not just:

IF
RGB bulb is red
THEN
With audio
Set volume
Play x
ELSE
With audio
Stop
With RGB bulb
Turn on


#3

The issue is you can’t get the color info you need. See the logs above. When acquiring the color information you get back a ton of extra information and not just the color hex.


#4

Can you show me a log event for a color change, not switch event

Just make a piston:

IF
RGB color is red
THEN
log info $currentEventValue


#5

It is in the Graph IDE image. SetColor [hue:100, saturation:100, level:100, color:#ff0000]

That is the string you get from the simulated RGB bulb. If I do this with a regular RGB bulb and ask for color it comes back correctly for an “if” statement. BUT I do not want to have a regular bulb plugged in to do this. The Simulated RGB DTH is giving this info back incorrectly in ST. Hence why I need to parse the string with a contains first and also why I can’t trigger based off of just color changing.


#6

Try using a non-simulated device handler, in a simulated manner.

For example, try the ST default handler for Fibaro RGBW (the second one in the list).


#7

I have. SHM will not set its color unfortunately. :frowning:

I believe I am going to call ST today and discover what is going on.


#8

Is there a particular reason why you are using a simulated RGB over a simulated switch?

You only appear to be referencing two states (red and white) so why not on / off?


#9

SHM doesn’t turn the light off unfortunately.

Overall my issues is working with SHM. I wish I could see more than arm/disarm such as I would like to see intrusions etc.


#10

Called ST and they couldn’t help. Oh well. I went with a different method based on other posts in the community.