Execution order of triggers or conditions


#1

What is the correct order to place the triggers? In this Piston, my thought was that it would see the Garage lights on for 3 minutes, and then check if there was motion on either of the 2 motion sensors in the last 60 seconds. It doesn’t look like I can make it check for motion in the last 60 seconds, only if there has been motion FOR 60 seconds.

Am I missing it?


#2

What about something like this…(add your top Garage Light Keep ON on top)


#3

That might work. I’ll give it a try.

So,… it is correct to have the switch first then the motion sensors second? I see you have them in the same order.

What would happen to your Piston if motion is detected in the middle of the 3 minutes, but is inactive at the time it checks? My goal here is to have the lights turn off in 3 minutes of turning on, EXCEPT if there is motion in that 3 minutes, thereby giving me another 3 minutes.


#4

Regarding placement, it is recommended to put triggers up top (the ones with orange lightning bolt). Putting them somewhere else sometimes causes unexpected behavior since pistons get evaluated from top to bottom.

On the motion question, that’s something I’d have to try as I didn’t even test that piston when I posted it :slight_smile:


#5

Thanks!

Reason I’m asking is because it seems the time it takes for these motion sensors to change from active to inactive is 30 seconds.

So… if in that 3 minute window, after 2 minutes the motion detector could be triggered to active, 30 seconds later it might be inactive, then the lights would go out, when actually I would like the trigger to active to give me 3 more minutes. Not shut off. Make sense?


#6

What about just doing it like this with just the flat 3 minute wait? Each active motion event resets it to 3 minutes.


#7

That would be perfect! Very simple.

I’ll test it out. I don’t understand how this resets the 3 minutes upon motion though.


#8

Any active event from the motion sensors will reset the 3 minute wait until the next time both of the sensors report inactive.


#9

Thank you.

If this works on the garage, I can use for the very similar set up in the basement.


#10

It worked just like you said it would!

It had 2 “Piston waited at a semaphore”. Are those bad?

1/26/2022, 8:40:17 PM +295ms
+2ms ╔Received event [Garage Lights].switch = off with a delay of 291ms
+10089ms ║RunTime Analysis CS > 21ms > PS > 10045ms > PE > 23ms > CE
+10090ms ║Piston waited at a semaphore for 10041ms
+10092ms ║Runtime (38123 bytes) successfully initialized in 10045ms (v0.3.113.20210203) (10090ms)
+10094ms ║╔Execution stage started
+10106ms ║║Comparison (enum) off is (string) off = true (1ms)
+10108ms ║║Condition #1 evaluated true (10ms)
+10109ms ║║Condition group #null evaluated true (state did not change) (11ms)
+10116ms ║║Comparison (enum) off is (string) on = false (1ms)
+10117ms ║║Condition #3 evaluated false (6ms)
+10118ms ║║Condition group #2 evaluated false (state did not change) (7ms)
+10120ms ║╚Execution stage complete. (27ms)
+10121ms ╚Event processed successfully (10121ms)
1/26/2022, 8:40:17 PM +259ms
+2ms ╔Received event [Garage Lights].switch = off with a delay of 255ms
+58ms ║RunTime Analysis CS > 26ms > PS > 8ms > PE > 24ms > CE
+61ms ║Runtime (38034 bytes) successfully initialized in 8ms (v0.3.113.20210203) (59ms)
+62ms ║╔Execution stage started
+74ms ║║Comparison (enum) off is (string) off = true (1ms)
+76ms ║║Condition #1 evaluated true (10ms)
+77ms ║║Condition group #null evaluated true (state did not change) (12ms)
+85ms ║║Comparison (enum) off is (string) on = false (1ms)
+87ms ║║Cancelling condition #3’s schedules…
+88ms ║║Condition #3 evaluated false (7ms)
+89ms ║║Cancelling condition #2’s schedules…
+90ms ║║Condition group #2 evaluated false (state changed) (10ms)
+92ms ║╚Execution stage complete. (30ms)
+93ms ╚Event processed successfully (93ms)
1/26/2022, 8:40:16 PM +104ms
+0ms ╔Received event [Home].time = 1643247617089 with a delay of -986ms
+40ms ║RunTime Analysis CS > 18ms > PS > 7ms > PE > 16ms > CE
+43ms ║Runtime (38034 bytes) successfully initialized in 7ms (v0.3.113.20210203) (41ms)
+44ms ║╔Execution stage started
+74ms ║║Executed physical command [Garage Lights].off() (18ms)
+76ms ║║Executed [Garage Lights].off (20ms)
+78ms ║╚Execution stage complete. (35ms)
+84ms ╚Event processed successfully (85ms)
1/26/2022, 8:37:16 PM +988ms
+1ms ╔Received event [Garage Motion 2].motion = inactive with a delay of 100ms
+47ms ║RunTime Analysis CS > 18ms > PS > 13ms > PE > 16ms > CE
+50ms ║Runtime (38046 bytes) successfully initialized in 13ms (v0.3.113.20210203) (48ms)
+51ms ║╔Execution stage started
+61ms ║║Comparison (enum) off is (string) off = true (1ms)
+62ms ║║Condition #1 evaluated true (8ms)
+63ms ║║Condition group #null evaluated true (state did not change) (9ms)
+72ms ║║Comparison (enum) on is (string) on = true (1ms)
+74ms ║║Condition #3 evaluated true (8ms)
+83ms ║║Comparison (enum) inactive is (string) inactive = true (1ms)
+85ms ║║Comparison (enum) inactive is (string) inactive = true (1ms)
+87ms ║║Cancelling condition #5’s schedules…
+88ms ║║Condition #5 evaluated true (13ms)
+89ms ║║Cancelling condition #2’s schedules…
+90ms ║║Condition group #2 evaluated true (state changed) (25ms)
+93ms ║║Condition group #4 evaluated true (state did not change) (0ms)
+95ms ║║Cancelling statement #6’s schedules…
+99ms ║║Executed virtual command [Garage Lights].wait (1ms)
+100ms ║║Requesting a wake up for Wed, Jan 26 2022 @ 8:40:17 PM EST (in 180.0s)
+105ms ║╚Execution stage complete. (55ms)
+107ms ║Setting up scheduled job for Wed, Jan 26 2022 @ 8:40:17 PM EST (in 179s)
+113ms ╚Event processed successfully (113ms)
1/26/2022, 8:36:46 PM +61ms
+1ms ╔Received event [Garage Motion 2].motion = active with a delay of 156ms
+41ms ║RunTime Analysis CS > 18ms > PS > 7ms > PE > 16ms > CE
+44ms ║Runtime (38039 bytes) successfully initialized in 7ms (v0.3.113.20210203) (42ms)
+45ms ║╔Execution stage started
+56ms ║║Comparison (enum) off is (string) off = true (2ms)
+58ms ║║Condition #1 evaluated true (8ms)
+59ms ║║Condition group #null evaluated true (state did not change) (10ms)
+70ms ║║Comparison (enum) on is (string) on = true (1ms)
+72ms ║║Condition #3 evaluated true (11ms)
+82ms ║║Comparison (enum) inactive is (string) inactive = true (2ms)
+85ms ║║Comparison (enum) active is (string) inactive = false (2ms)
+87ms ║║Cancelling condition #5’s schedules…
+88ms ║║Condition #5 evaluated false (15ms)
+89ms ║║Cancelling condition #2’s schedules…
+90ms ║║Condition group #2 evaluated false (state changed) (29ms)
+93ms ║╚Execution stage complete. (48ms)
+100ms ╚Event processed successfully (100ms)
1/26/2022, 8:35:57 PM +675ms
+0ms ╔Received event [Garage Lights].switch = on with a delay of 81ms
+41ms ║RunTime Analysis CS > 22ms > PS > 7ms > PE > 12ms > CE
+49ms ║Runtime (38038 bytes) successfully initialized in 7ms (v0.3.113.20210203) (42ms)
+50ms ║╔Execution stage started
+59ms ║║Comparison (enum) off is (string) off = true (1ms)
+61ms ║║Condition #1 evaluated true (8ms)
+62ms ║║Condition group #null evaluated true (state did not change) (9ms)
+68ms ║║Comparison (enum) on is (string) on = true (1ms)
+70ms ║║Cancelling condition #3’s schedules…
+71ms ║║Condition #3 evaluated true (6ms)
+83ms ║║Comparison (enum) inactive is (string) inactive = true (1ms)
+86ms ║║Comparison (enum) inactive is (string) inactive = true (2ms)
+87ms ║║Condition #5 evaluated true (16ms)
+88ms ║║Cancelling condition #2’s schedules…
+89ms ║║Condition group #2 evaluated true (state changed) (25ms)
+92ms ║║Condition group #4 evaluated true (state did not change) (1ms)
+94ms ║║Cancelling statement #6’s schedules…
+98ms ║║Executed virtual command [Garage Lights].wait (0ms)
+100ms ║║Requesting a wake up for Wed, Jan 26 2022 @ 8:38:57 PM EST (in 180.0s)
+105ms ║╚Execution stage complete. (54ms)
+106ms ║Setting up scheduled job for Wed, Jan 26 2022 @ 8:38:57 PM EST (in 179s)
+118ms ╚Event processed successfully (119ms)
1/26/2022, 8:35:57 PM +672ms
+0ms ╔Received event [Garage Lights].switch = on with a delay of 78ms
+45ms ║RunTime Analysis CS > 24ms > PS > 7ms > PE > 14ms > CE
+47ms ║Runtime (38038 bytes) successfully initialized in 7ms (v0.3.113.20210203) (46ms)
+48ms ║╔Execution stage started
+58ms ║║Comparison (enum) off is (string) off = true (1ms)
+59ms ║║Condition #1 evaluated true (8ms)
+60ms ║║Condition group #null evaluated true (state did not change) (9ms)
+66ms ║║Comparison (enum) on is (string) on = true (2ms)
+67ms ║║Cancelling condition #3’s schedules…
+68ms ║║Condition #3 evaluated true (6ms)
+81ms ║║Comparison (enum) inactive is (string) inactive = true (2ms)
+83ms ║║Comparison (enum) inactive is (string) inactive = true (1ms)
+85ms ║║Condition #5 evaluated true (16ms)
+86ms ║║Cancelling condition #2’s schedules…
+87ms ║║Condition group #2 evaluated true (state changed) (24ms)
+89ms ║║Condition group #4 evaluated true (state did not change) (1ms)
+91ms ║║Cancelling statement #6’s schedules…
+95ms ║║Executed virtual command [Garage Lights].wait (0ms)
+97ms ║║Requesting a wake up for Wed, Jan 26 2022 @ 8:38:57 PM EST (in 180.0s)
+101ms ║╚Execution stage complete. (53ms)
+103ms ║Setting up scheduled job for Wed, Jan 26 2022 @ 8:38:57 PM EST (in 179s)
+113ms ╚Event processed successfully (114ms)
1/26/2022, 8:35:56 PM +964ms
+1ms ╔Received event [Garage Lights].switch = off with a delay of 161ms
+49ms ║RunTime Analysis CS > 25ms > PS > 7ms > PE > 17ms > CE
+52ms ║Runtime (38034 bytes) successfully initialized in 7ms (v0.3.113.20210203) (50ms)
+53ms ║╔Execution stage started
+64ms ║║Comparison (enum) off is (string) off = true (1ms)
+65ms ║║Condition #1 evaluated true (9ms)
+66ms ║║Condition group #null evaluated true (state did not change) (11ms)
+72ms ║║Comparison (enum) off is (string) on = false (2ms)
+73ms ║║Cancelling condition #3’s schedules…
+74ms ║║Condition #3 evaluated false (6ms)
+75ms ║║Cancelling condition #2’s schedules…
+76ms ║║Condition group #2 evaluated false (state changed) (8ms)
+78ms ║╚Execution stage complete. (26ms)
+79ms ╚Event processed successfully (79ms)
1/26/2022, 8:35:56 PM +56ms
+1ms ╔Received event [Home].time = 1643247357112 with a delay of -1056ms
+36ms ║RunTime Analysis CS > 17ms > PS > 7ms > PE > 12ms > CE
+38ms ║Runtime (38035 bytes) successfully initialized in 7ms (v0.3.113.20210203) (36ms)
+39ms ║╔Execution stage started
+134ms ║║Executed physical command [Garage Lights].off() (81ms)
+135ms ║║Executed [Garage Lights].off (83ms)
+137ms ║╚Execution stage complete. (98ms)
+144ms ╚Event processed successfully (143ms)
1/26/2022, 8:32:46 PM +930ms
+1ms ╔Received event [Garage Lights].switch = on with a delay of 151ms
+10127ms ║RunTime Analysis CS > 27ms > PS > 10077ms > PE > 24ms > CE
+10128ms ║Piston waited at a semaphore for 10072ms
+10131ms ║Runtime (38116 bytes) successfully initialized in 10077ms (v0.3.113.20210203) (10128ms)
+10131ms ║╔Execution stage started
+10142ms ║║Comparison (enum) off is (string) off = true (1ms)
+10143ms ║║Condition #1 evaluated true (8ms)
+10144ms ║║Condition group #null evaluated true (state did not change) (10ms)
+10150ms ║║Comparison (enum) on is (string) on = true (1ms)
+10152ms ║║Condition #3 evaluated true (6ms)
+10165ms ║║Comparison (enum) inactive is (string) inactive = true (2ms)
+10167ms ║║Comparison (enum) inactive is (string) inactive = true (1ms)
+10169ms ║║Condition #5 evaluated true (16ms)
+10170ms ║║Condition group #2 evaluated true (state did not change) (24ms)
+10173ms ║║Condition group #4 evaluated true (state did not change) (1ms)
+10175ms ║║Cancelling statement #6’s schedules…
+10180ms ║║Executed virtual command [Garage Lights].wait (0ms)
+10181ms ║║Requesting a wake up for Wed, Jan 26 2022 @ 8:35:57 PM EST (in 180.0s)
+10186ms ║╚Execution stage complete. (54ms)
+10187ms ║Setting up scheduled job for Wed, Jan 26 2022 @ 8:35:57 PM EST (in 179s)
+10202ms ╚Event processed successfully (10201ms)
1/26/2022, 8:32:46 PM +857ms
+1ms ╔Received event [Garage Lights].switch = on with a delay of 79ms
+59ms ║RunTime Analysis CS > 31ms > PS > 7ms > PE > 20ms > CE
+61ms ║Runtime (38038 bytes) successfully initialized in 7ms (v0.3.113.20210203) (59ms)
+62ms ║╔Execution stage started
+78ms ║║Comparison (enum) off is (string) off = true (2ms)
+80ms ║║Condition #1 evaluated true (13ms)
+81ms ║║Condition group #null evaluated true (state did not change) (15ms)
+87ms ║║Comparison (enum) on is (string) on = true (1ms)
+89ms ║║Cancelling condition #3’s schedules…
+90ms ║║Condition #3 evaluated true (7ms)
+102ms ║║Comparison (enum) inactive is (string) inactive = true (2ms)
+104ms ║║Comparison (enum) inactive is (string) inactive = true (1ms)
+106ms ║║Condition #5 evaluated true (15ms)
+107ms ║║Cancelling condition #2’s schedules…
+108ms ║║Condition group #2 evaluated true (state changed) (25ms)
+111ms ║║Condition group #4 evaluated true (state did not change) (1ms)
+113ms ║║Cancelling statement #6’s schedules…
+118ms ║║Executed virtual command [Garage Lights].wait (1ms)
+119ms ║║Requesting a wake up for Wed, Jan 26 2022 @ 8:35:46 PM EST (in 180.0s)
+125ms ║╚Execution stage complete. (63ms)
+126ms ║Setting up scheduled job for Wed, Jan 26 2022 @ 8:35:46 PM EST (in 179s)
+134ms ╚Event processed successfully (134ms)


#11

The default behaviour of webCoRE is to try and serialise execution of piston instances. So if a piston receives an event while it is already executing it will ‘wait at a semaphore’ for up to ten seconds (more often than not it seems to be the full ten seconds) to give the previous instance a change to finish. It is just to stop them interfering with each other. Sometimes it isn’t that big a deal, other times it can be an issue.

In your case it would appear that ‘on’ events for your Garage Lights switch are being duplicated. So the semaphore wait would be like receiving two ‘on’ events ten seconds apart.

Going back to your original post, if the was condition didn’t work it probably means that it evaluated as ‘was NOT (active for less than 60 seconds)’ which isn’t what you want at all. So it is better to test for ‘was inactive for less than 60 seconds’.


#12

Thanks @orangebucket , you are correct on the two on events. ( I think ). The first on event would be the opening of the door, followed by the motion sensor on the other side of the door. It seems to be working fine now, so I’ll leave the sensor where it is for now. It is where it needs to be to catch motion coming the other way, on the other side of the door. I now understand what a semaphore is!