Help, issues with basic "wait" functions

Some help with the below would be greatly appreciated before i pull all my hair out :wink:.

I would like a light to be turned on when the location mode is set to X then wait for Y seconds and turn off. The issue that i’m having is that the “wait” counts down from Y seconds to zero, i get a red “pending” notification then, the timer counts up indefinitely and the light doesn’t turn off. The frustrating part is that i did have it working before the latest update where, in all of the updating excitement, i deleted all my pistons. Doh!!

In the attached piston you can see both methods that i have tried… Post update i get “Waited at a semaphore” a lot which i didn’t notice before? I am a noob so may be missing something obvious but, like i say, i did have it working on a previous piston.

Thanks for the help :+1:
#backupyourpistons

5/26/2019, 11:11:23 PM +750ms
+2ms ╔Received event [Hue Motion Sensor (Hall)].motion = inactive with a delay of 76ms
+95ms ║RunTime Analysis CS > 29ms > PS > 40ms > PE > 26ms > CE
+98ms ║Runtime (42107 bytes) successfully initialized in 40ms (v0.3.10c.20190522) (94ms)
+99ms ║╔Execution stage started
+110ms ║║Comparison (string) :b1145e97320e276312b238cef7c0dc4e: is_any_of (string) :302bcc01d8fc7d79826d917e0169f855:,:4741a60e498c1b32b57b46dfce8e2ee0: = false (3ms)
+191ms ║║Condition #16 evaluated false (86ms)
+193ms ║║Condition group #1 evaluated false (state did not change) (88ms)
+205ms ║║Comparison (integer) 0 is_less_than_or_equal_to (integer) 10 = true (2ms)
+207ms ║║Condition #30 evaluated true (10ms)
+213ms ║║Comparison (enum) inactive is (string) active = false (2ms)
+215ms ║║Cancelling condition #31’s schedules…
+216ms ║║Condition #31 evaluated false (8ms)
+217ms ║║Cancelling condition #29’s schedules…
+218ms ║║Condition group #29 evaluated false (state changed) (22ms)
+221ms ║║Cancelling statement #33’s schedules…
+227ms ║║Executed virtual command [Hue ambiance spot 2].wait (1ms)
+229ms ║║Requesting a wake up for Sun, May 26 2019 @ 11:12:23 PM BST (in 60.0s)
+238ms ║╚Execution stage complete. (138ms)
+240ms ║Setting up scheduled job for Sun, May 26 2019 @ 11:12:23 PM BST (in 59.991s)
+249ms ╚Event processed successfully (249ms)
5/26/2019, 11:10:53 PM +771ms
+1ms ╔Received event [Hue Motion Sensor (Hall)].motion = active with a delay of 88ms
+111ms ║RunTime Analysis CS > 30ms > PS > 42ms > PE > 39ms > CE
+114ms ║Runtime (42113 bytes) successfully initialized in 42ms (v0.3.10c.20190522) (111ms)
+115ms ║╔Execution stage started
+128ms ║║Comparison (string) :b1145e97320e276312b238cef7c0dc4e: is_any_of (string) :302bcc01d8fc7d79826d917e0169f855:,:4741a60e498c1b32b57b46dfce8e2ee0: = false (3ms)
+130ms ║║Condition #16 evaluated false (8ms)
+132ms ║║Condition group #1 evaluated false (state did not change) (9ms)
+144ms ║║Comparison (integer) 0 is_less_than_or_equal_to (integer) 10 = true (2ms)
+146ms ║║Condition #30 evaluated true (11ms)
+153ms ║║Comparison (enum) active is (string) active = true (2ms)
+155ms ║║Cancelling condition #31’s schedules…
+157ms ║║Condition #31 evaluated true (9ms)
+158ms ║║Cancelling condition #29’s schedules…
+160ms ║║Condition group #29 evaluated true (state changed) (24ms)
+168ms ║║Comparison (string) :b1145e97320e276312b238cef7c0dc4e: is (string) :b1145e97320e276312b238cef7c0dc4e: = true (2ms)
+170ms ║║Condition #36 evaluated true (7ms)
+171ms ║║Condition group #32 evaluated true (state did not change) (9ms)
+173ms ║║Condition group #32 evaluated true (state did not change) (1ms)
+177ms ║║Cancelling statement #37’s schedules…
+197ms ║║Executed physical command [Hue ambiance spot 2].on() (16ms)
+199ms ║║Executed [Hue ambiance spot 2].on (18ms)
+215ms ║║Executed physical command [Hue ambiance spot 2].setColorTemperature([4100]) (11ms)
+216ms ║║Executed [Hue ambiance spot 2].setColorTemperature (13ms)
+237ms ║║Executed physical command [Hue ambiance spot 2].setLevel([30]) (15ms)
+238ms ║║Executed [Hue ambiance spot 2].setLevel (18ms)
+242ms ║╚Execution stage complete. (128ms)
+244ms ╚Event processed successfully (244ms)
5/26/2019, 11:09:56 PM +425ms
+1ms ╔Starting piston… (v0.3.10c.20190522)
+185ms ║╔Subscribing to devices…
+216ms ║║Subscribing to Home.mode…
+226ms ║║Subscribing to Hue Motion Sensor (Hall).illuminance…
+236ms ║║Subscribing to Hue Motion Sensor (Hall).motion…
+291ms ║║Subscribing to Hue ambiance spot 2…
+293ms ║║Subscribing to Hue ambiance spot 1…
+294ms ║║Subscribing to Hue ambiance spot 3…
+296ms ║╚Finished subscribing (121ms)
+330ms ║Comparison (string) :b1145e97320e276312b238cef7c0dc4e: is_any_of (string) :302bcc01d8fc7d79826d917e0169f855:,:4741a60e498c1b32b57b46dfce8e2ee0: = false (4ms)
+345ms ║Comparison (integer) 0 is_less_than_or_equal_to (integer) 10 = true (2ms)
+356ms ║Comparison (enum) inactive is (string) active = false (3ms)
+388ms ║Comparison (integer) 0 is_less_than_or_equal_to (integer) 10 = true (3ms)
+400ms ║Comparison (enum) inactive is (string) active = false (3ms)
+410ms ║Comparison (string) :b1145e97320e276312b238cef7c0dc4e: is (string) :b1145e97320e276312b238cef7c0dc4e: = true (3ms)
+427ms ╚Piston successfully started (425ms)
5/26/2019, 11:08:20 PM +458ms
+1ms ╔Received event [Hue Motion Sensor (Hall)].motion = inactive with a delay of 62ms
+84ms ║RunTime Analysis CS > 18ms > PS > 41ms > PE > 25ms > CE
+86ms ║Runtime (42107 bytes) successfully initialized in 41ms (v0.3.10c.20190522) (84ms)
+88ms ║╔Execution stage started
+100ms ║║Comparison (string) :b1145e97320e276312b238cef7c0dc4e: is_any_of (string) :302bcc01d8fc7d79826d917e0169f855:,:4741a60e498c1b32b57b46dfce8e2ee0: = false (3ms)
+102ms ║║Condition #16 evaluated false (8ms)
+103ms ║║Condition group #1 evaluated false (state did not change) (9ms)
+116ms ║║Comparison (integer) 0 is_less_than_or_equal_to (integer) 10 = true (2ms)
+118ms ║║Condition #30 evaluated true (11ms)
+125ms ║║Comparison (enum) inactive is (string) active = false (2ms)
+127ms ║║Cancelling condition #31’s schedules…
+128ms ║║Condition #31 evaluated false (9ms)
+130ms ║║Cancelling condition #29’s schedules…
+131ms ║║Condition group #29 evaluated false (state changed) (24ms)
+134ms ║╚Execution stage complete. (47ms)
+135ms ╚Event processed successfully (135ms)
5/26/2019, 11:07:50 PM +490ms
+1ms ╔Received event [Hue Motion Sensor (Hall)].motion = active with a delay of 89ms
+103ms ║RunTime Analysis CS > 28ms > PS > 40ms > PE > 34ms > CE
+105ms ║Runtime (42110 bytes) successfully initialized in 40ms (v0.3.10c.20190522) (103ms)
+107ms ║╔Execution stage started
+119ms ║║Comparison (string) :b1145e97320e276312b238cef7c0dc4e: is_any_of (string) :302bcc01d8fc7d79826d917e0169f855:,:4741a60e498c1b32b57b46dfce8e2ee0: = false (3ms)
+121ms ║║Condition #16 evaluated false (7ms)
+122ms ║║Condition group #1 evaluated false (state did not change) (9ms)
+134ms ║║Comparison (integer) 0 is_less_than_or_equal_to (integer) 10 = true (2ms)
+136ms ║║Condition #30 evaluated true (10ms)
+142ms ║║Comparison (enum) active is (string) active = true (2ms)
+144ms ║║Cancelling condition #31’s schedules…
+146ms ║║Condition #31 evaluated true (8ms)
+147ms ║║Cancelling condition #29’s schedules…
+148ms ║║Condition group #29 evaluated true (state changed) (23ms)
+156ms ║║Comparison (string) :b1145e97320e276312b238cef7c0dc4e: is (string) :b1145e97320e276312b238cef7c0dc4e: = true (2ms)
+158ms ║║Condition #36 evaluated true (6ms)
+159ms ║║Condition group #32 evaluated true (state did not change) (9ms)
+161ms ║║Condition group #32 evaluated true (state did not change) (1ms)
+164ms ║║Cancelling statement #37’s schedules…
+184ms ║║Executed physical command [Hue ambiance spot 2].on() (16ms)
+185ms ║║Executed [Hue ambiance spot 2].on (18ms)
+201ms ║║Executed physical command [Hue ambiance spot 2].setColorTemperature([4100]) (11ms)
+202ms ║║Executed [Hue ambiance spot 2].setColorTemperature (13ms)
+223ms ║║Executed physical command [Hue ambiance spot 2].setLevel([30]) (15ms)
+224ms ║║Executed [Hue ambiance spot 2].setLevel (17ms)
+228ms ║╚Execution stage complete. (121ms)
+229ms ╚Event processed successfully (229ms)
5/26/2019, 11:06:48 PM +650ms
+1ms ╔Starting piston… (v0.3.10c.20190522)
+221ms ║╔Subscribing to devices…
+277ms ║║Subscribing to Home.mode…
+289ms ║║Subscribing to Hue Motion Sensor (Hall).illuminance…
+301ms ║║Subscribing to Hue Motion Sensor (Hall).motion…
+374ms ║║Subscribing to Hue ambiance spot 2…
+375ms ║║Subscribing to Hue ambiance spot 1…
+377ms ║║Subscribing to Hue ambiance spot 3…
+378ms ║╚Finished subscribing (167ms)
+410ms ║Comparison (string) :b1145e97320e276312b238cef7c0dc4e: is_any_of (string) :302bcc01d8fc7d79826d917e0169f855:,:4741a60e498c1b32b57b46dfce8e2ee0: = false (4ms)
+425ms ║Comparison (integer) 0 is_less_than_or_equal_to (integer) 10 = true (2ms)
+436ms ║Comparison (enum) inactive is (string) active = false (2ms)
+474ms ║Comparison (integer) 0 is_less_than_or_equal_to (integer) 10 = true (2ms)
+484ms ║Comparison (enum) inactive is (string) active = false (2ms)
+495ms ║Comparison (string) :b1145e97320e276312b238cef7c0dc4e: is (string) :b1145e97320e276312b238cef7c0dc4e: = true (2ms)
+497ms ║Cancelling condition #36’s schedules…
+499ms ║Cancelling condition #32’s schedules…
+523ms ╚Piston successfully started (521ms)
5/26/2019, 11:02:22 PM +773ms
+1ms ╔Starting piston… (v0.3.10c.20190522)
+237ms ║╔Subscribing to devices…
+292ms ║║Subscribing to Home.mode…
+305ms ║║Subscribing to Hue Motion Sensor (Hall).illuminance…
+319ms ║║Subscribing to Hue Motion Sensor (Hall).motion…
+409ms ║║Subscribing to Hue ambiance spot 2…
+410ms ║║Subscribing to Hue ambiance spot 1…
+412ms ║║Subscribing to Hue ambiance spot 3…
+413ms ║╚Finished subscribing (194ms)
+452ms ║Comparison (string) :b1145e97320e276312b238cef7c0dc4e: is_any_of (string) :302bcc01d8fc7d79826d917e0169f855:,:4741a60e498c1b32b57b46dfce8e2ee0: = false (4ms)
+467ms ║Comparison (integer) 0 is_less_than_or_equal_to (integer) 10 = true (2ms)
+479ms ║Comparison (enum) inactive is (string) active = false (3ms)
+520ms ║Comparison (integer) 0 is_less_than_or_equal_to (integer) 10 = true (2ms)
+531ms ║Comparison (enum) inactive is (string) active = false (2ms)
+533ms ║Cancelling condition #17’s schedules…
+543ms ║Comparison (string) :b1145e97320e276312b238cef7c0dc4e: is (string) :b1145e97320e276312b238cef7c0dc4e: = true (2ms)
+545ms ║Cancelling condition #30’s schedules…
+547ms ║Cancelling condition #19’s schedules…
+567ms ╚Piston successfully started (566ms)
5/26/2019, 10:56:37 PM +364ms
+62ms ╔Received event [Home].time = 1558907782751 with a delay of 14612ms
+1253ms ║RunTime Analysis CS > 257ms > PS > 572ms > PE > 424ms > CE
+1257ms ║Runtime (41693 bytes) successfully initialized in 572ms (v0.3.10c.20190522) (1193ms)
+1258ms ║╔Execution stage started
+2625ms ║║Executed physical command [Hue ambiance spot 2].off() (17ms)
+2627ms ║║Executed [Hue ambiance spot 2].off (20ms)
+2788ms ║╚Execution stage complete. (1530ms)
+2791ms ╚Event processed successfully (2792ms)
5/26/2019, 10:55:22 PM +596ms
+0ms ╔Received event [Home].execute = recovery with a delay of 54ms
+86ms ║RunTime Analysis CS > 27ms > PS > 40ms > PE > 20ms > CE
+89ms ║Runtime (41681 bytes) successfully initialized in 40ms (v0.3.10c.20190522) (88ms)
+90ms ║╔Execution stage started
+102ms ║║Comparison (string) :b1145e97320e276312b238cef7c0dc4e: is_any_of (string) :302bcc01d8fc7d79826d917e0169f855:,:4741a60e498c1b32b57b46dfce8e2ee0: = false (2ms)
+104ms ║║Condition #16 evaluated false (7ms)
+105ms ║║Condition group #1 evaluated false (state did not change) (9ms)
+113ms ║║Comparison (string) :b1145e97320e276312b238cef7c0dc4e: is (string) :b1145e97320e276312b238cef7c0dc4e: = true (2ms)
+115ms ║║Condition #18 evaluated true (6ms)
+116ms ║║Condition group #17 evaluated true (state did not change) (8ms)
+128ms ║║Comparison (integer) 0 is_less_than_or_equal_to (integer) 10 = true (2ms)
+130ms ║║Condition #20 evaluated true (11ms)
+139ms ║║Comparison (enum) inactive is (string) active = false (2ms)
+141ms ║║Condition #21 evaluated false (10ms)
+142ms ║║Condition group #19 evaluated false (state did not change) (23ms)
+146ms ║║Cancelling statement #29’s schedules…
+152ms ║║Executed virtual command [Hue ambiance spot 2].wait (1ms)
+154ms ║║Requesting a wake up for Sun, May 26 2019 @ 10:56:22 PM BST (in 60.0s)
+164ms ║╚Execution stage complete. (75ms)
+166ms ║Setting up scheduled job for Sun, May 26 2019 @ 10:56:22 PM BST (in 59.99s)
+176ms ╚Event processed successfully (175ms)
5/26/2019, 10:51:32 PM +924ms
+10086ms ║Piston waited at a semaphore for 10024ms

If
Motion sensor motion changes to active
And
Motion sensor illuminance is less than or equal to 101 lux ( I prefer time is between sunset and sunrise but that is my preference)

Then
With
Kitchen lights
Turn on
Blah blah blah

Else
With kitchen lights
Wait 5 minutes
Turn off

Note: always put the trigger in the first line. In your case, motion is detected and then put the conditions after

Thank for the advice, i'll give it a go. Hopefully it is the last time i see a Semaphore!! lol.

If i wanted to have multiple rooms being controlled by individual motion sensors within the same time period, will it work with an all encompassing IF Location mode is set to X statement? Please see the example below. Or, is it better to set it up as you suggest but multiple times for individual rooms with the same time conditions whilst in the same piston? Or, is 1 Piston for 1 Room the way to go?:

if
location mode is set to home

then
if
Motion sensor motion changes to active
And
Motion sensor illuminance is less than or equal to 101 lux

Then
With
Kitchen lights
Turn on
Blah blah blah

Else
With kitchen lights
Wait 5 minutes

Turn off

end if

if
Motion sensor motion 2 changes to active
And
Motion sensor 2 illuminance is less than or equal to 101 lux

then
Study
blah blah blah

end if

end if

end execute

@jkp

Just a quick update, I set the piston as you suggested and set the wait to to 30sec to test it. The first time the lights stayed on. (with Trace on the count down timer got to zero, changed to pending and started counting up). Same problem. After 5min i triggered the motion sensor again but this time after 30sec it worked. Strange. I tested it a few more times with mixed results. It seems to be every other trigger event whether the “wait” “turn off” function works or not. It would be interesting to see if anyone else was having to same problem?

You should post on the webCoRE forum. They enjoy helping with the building of pistons. There are also lots of example pistons you can look at for guidance.

Awesome, thanks! I’ll check the link out.