Need help with global variable timing between 2 pistons


#1

1) Give a description of the problem
Following up on my alternative approach (/using-programatic-interaction/5570/4), I went back to the original logic in the virtual switch logic.

I’ve set up the logic in the latter thread by using a global variable.

2) What is the expected behavior?
When I turn on an individual switch (1-5) the virtual Switch 9 should turn on. The rest of switches should not change their state.

3) What is happening/not happening?
The virtual Switch 9 is turning on, however, the “execute” piston is also firing. EG, if I turn on switch 1, the global variable AllOutdoorLightsHOLD variable should be set to true. However, the “execute” piston is somehow picking up that the global variable is evaluating to false.

Best I can tell, there is a delay in the “hold” piston so the “execute” piston is running before the variable is set:

3/19/2018, 9:05:38 AM +923ms
....
+6624ms|║RunTime Analysis CS > 20ms > PS > 6567ms > PE > 36ms > CE|
+6625ms|║Piston waited at a semaphore for 6519ms|

**4) Post a Green Snapshot of the piston
The “Hold” piston

The “execute” piston

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

Hold logs

3/19/2018, 9:05:39 AM +278ms
+1ms	╔Received event [Luxor ZDC Controller].switch = on with a delay of 49ms
+6346ms	║RunTime Analysis CS > 11ms > PS > 6295ms > PE > 40ms > CE
+6347ms	║Piston waited at a semaphore for 6262ms
+6350ms	║Runtime (40294 bytes) successfully initialized in 6295ms (v0.3.000.20180224) (6347ms)
+6351ms	║╔Execution stage started
+6377ms	║║Comparison (enum) on changes_to (string) on = true (1ms)
+6379ms	║║Condition #14 evaluated true (22ms)
+6380ms	║║Condition group #1 evaluated true (state did not change) (24ms)
+6387ms	║║Executed virtual command [All Outdoor Lights].setVariable (1ms)
+6390ms	║║Executed virtual command [All Outdoor Lights].wait (0ms)
+6391ms	║║Waiting for 3000ms
+9403ms	║║Skipped execution of physical command [All Outdoor Lights].on([]) because it would make no change to the device. (9ms)
+9404ms	║║Executed [All Outdoor Lights].on (11ms)
+9407ms	║║Executed virtual command [All Outdoor Lights].wait (0ms)
+9409ms	║║Requesting a wake up for Mon, Mar 19 2018 @ 9:05:51 AM PDT (in 3.0s)
+9413ms	║╚Execution stage complete. (3063ms)
+9414ms	║Setting up scheduled job for Mon, Mar 19 2018 @ 9:05:51 AM PDT (in 2.995s)
+9682ms	╚Event processed successfully (9682ms)

 3/19/2018, 9:05:38 AM +923ms
+2ms	╔Received event [Kitchen Outdoor Lights].switch = on with a delay of 56ms
+6624ms	║RunTime Analysis CS > 20ms > PS > 6567ms > PE > 36ms > CE
+6625ms	║Piston waited at a semaphore for 6519ms
+6627ms	║Runtime (40296 bytes) successfully initialized in 6567ms (v0.3.000.20180224) (6624ms)
+6628ms	║╔Execution stage started
+6655ms	║║Comparison (enum) on changes_to (string) on = true (0ms)
+6657ms	║║Condition #14 evaluated true (24ms)
+6658ms	║║Condition group #1 evaluated true (state did not change) (26ms)
+6665ms	║║Executed virtual command [All Outdoor Lights].setVariable (1ms)
+6668ms	║║Executed virtual command [All Outdoor Lights].wait (1ms)
+6669ms	║║Waiting for 3000ms
+9682ms	║║Skipped execution of physical command [All Outdoor Lights].on([]) because it would make no change to the device. (11ms)
+9683ms	║║Executed [All Outdoor Lights].on (12ms)
+9686ms	║║Executed virtual command [All Outdoor Lights].wait (1ms)
+9687ms	║║Requesting a wake up for Mon, Mar 19 2018 @ 9:05:51 AM PDT (in 3.0s)
+9690ms	║╚Execution stage complete. (3063ms)
+9692ms	║Setting up scheduled job for Mon, Mar 19 2018 @ 9:05:51 AM PDT (in 2.996s)
+9700ms	╚Event processed successfully (9700ms)

3/19/2018, 9:05:41 AM +652ms
+1ms	╔Received event [Pool (PATH LIGHTS)].switch = on with a delay of 66ms
+112ms	║RunTime Analysis CS > 28ms > PS > 47ms > PE > 36ms > CE
+114ms	║Runtime (40218 bytes) successfully initialized in 47ms (v0.3.000.20180224) (112ms)
+115ms	║╔Execution stage started
+141ms	║║Comparison (enum) on changes_to (string) on = true (0ms)
+143ms	║║Condition #14 evaluated true (24ms)
+144ms	║║Condition group #1 evaluated true (state did not change) (25ms)
+149ms	║║Executed virtual command [All Outdoor Lights].setVariable (1ms)
+152ms	║║Executed virtual command [All Outdoor Lights].wait (1ms)
+152ms	║║Waiting for 3000ms
+3157ms	║║Skipped execution of physical command [All Outdoor Lights].on([]) because it would make no change to the device. (2ms)
+3157ms	║║Executed [All Outdoor Lights].on (3ms)
+3160ms	║║Executed virtual command [All Outdoor Lights].wait (1ms)
+3160ms	║║Waiting for 3000ms
+6164ms	║║Executed virtual command [All Outdoor Lights].setVariable (1ms)
+6166ms	║╚Execution stage complete. (6051ms)
+6167ms	╚Event processed successfully (6167ms)

3/19/2018, 9:05:35 AM +313ms
+1ms	╔Received event [Garage And Driveway Relay].switch = on with a delay of 51ms
+79ms	║RunTime Analysis CS > 12ms > PS > 33ms > PE > 35ms > CE
+81ms	║Runtime (40230 bytes) successfully initialized in 33ms (v0.3.000.20180224) (80ms)
+82ms	║╔Execution stage started
+112ms	║║Comparison (enum) on changes_to (string) on = true (0ms)
+114ms	║║Cancelling condition #14's schedules...
+115ms	║║Condition #14 evaluated true (28ms)
+116ms	║║Cancelling condition #1's schedules...
+117ms	║║Condition group #1 evaluated true (state changed) (30ms)
+122ms	║║Executed virtual command [All Outdoor Lights].setVariable (1ms)
+126ms	║║Executed virtual command [All Outdoor Lights].wait (0ms)
+126ms	║║Waiting for 3000ms
+3154ms	║║Executed physical command [All Outdoor Lights].on() (25ms)
+3155ms	║║Executed [All Outdoor Lights].on (26ms)
+3157ms	║║Executed virtual command [All Outdoor Lights].wait (0ms)
+3158ms	║║Waiting for 3000ms
+6162ms	║║Executed virtual command [All Outdoor Lights].setVariable (1ms)
+6165ms	║╚Execution stage complete. (6083ms)
+6166ms	╚Event processed successfully (6166ms)

Execute logs

3/19/2018, 9:05:38 AM +498ms
+0ms	╔Received event [All Outdoor Lights].switch = on with a delay of 39ms
+63ms	║RunTime Analysis CS > 11ms > PS > 33ms > PE > 19ms > CE
+65ms	║Runtime (38430 bytes) successfully initialized in 33ms (v0.3.000.20180224) (64ms)
+66ms	║╔Execution stage started
+74ms	║║Comparison (enum) on changes_to (string) on = true (1ms)
+75ms	║║Cancelling condition #8's schedules...
+76ms	║║Condition #8 evaluated true (5ms)
+80ms	║║Comparison (boolean) false is (boolean) false = true (1ms)
+81ms	║║Condition #10 evaluated true (4ms)
+82ms	║║Cancelling condition #12's schedules...
+83ms	║║Condition group #12 evaluated true (state changed) (12ms)
+84ms	║║Cancelling condition #1's schedules...
+84ms	║║Condition group #1 evaluated true (state changed) (14ms)
+87ms	║║Cancelling statement #6's schedules...
+106ms	║║Executed physical command [Deck Lights].on() (16ms)
+107ms	║║Executed [Deck Lights].on (18ms)
+112ms	║║Skipped execution of physical command [Garage And Driveway Relay].on([]) because it would make no change to the device. (2ms)
+112ms	║║Executed [Garage And Driveway Relay].on (4ms)
+145ms	║║Executed physical command [Kitchen Outdoor Lights].on() (30ms)
+145ms	║║Executed [Kitchen Outdoor Lights].on (32ms)
+166ms	║║Executed physical command [Luxor ZDC Controller].on() (19ms)
+167ms	║║Executed [Luxor ZDC Controller].on (21ms)
+214ms	║║Executed physical command [Pool (PATH LIGHTS)].on() (46ms)
+215ms	║║Executed [Pool (PATH LIGHTS)].on (46ms)
+217ms	║╚Execution stage complete. (152ms)
+218ms	╚Event processed successfully (219ms)

#2

Have you tried ditching the global variable and replacing it with a second virtual switch instead?

That would probably update much faster and more reliably.


#3

I can certainly try that… but seems counter intuitive to me that something on the SmartThings hub/cloud as a device would be more responsive than just setting a variable local to WebCore… Will let you know how it turns out.


#4

@Mike1616 You were spot on… the 2nd virtual device works MUCH better than using a Global Variable. This is still confusing to me… but I have none of the issues I previously had.

Thanks! Looking forward to trying it tonight after sunset (these control my outdoor lights). :grin: