Light issue, sorry Im a newb


#1

1) Give a description of the problem
Lights are turning off when they shouldn’t

2) What is the expected behaviour?
Lights should stay on with motion detected

3) What is happening/not happening?
Lights are shutting off when there is motion in the room.

4) Post a Green Snapshot of the pistonimage

5) Attach logs after turning logging level to Full
11/1/2021, 5:30:17 PM +791ms
+0ms ╔Received event [Home].time = 1635805811014 with a delay of 6777ms
+126ms ║RunTime Analysis CS > 46ms > PS > 7ms > PE > 72ms > CE
+129ms ║Runtime (40482 bytes) successfully initialized in 7ms (v0.3.113.20210203) (127ms)
+130ms ║╔Execution stage started
+151ms ║║Cancelling condition #6’s schedules…
+153ms ║║Condition #6 evaluated true (1ms)
+154ms ║║Cancelling condition #5’s schedules…
+155ms ║║Condition group #5 evaluated true (state changed) (5ms)
+157ms ║║Cancelling statement #7’s schedules…
+188ms ║║Executed physical command [Bathroom left].off() (23ms)
+190ms ║║Executed virtual command [Bathroom left].setSwitch (25ms)
+223ms ║║Executed physical command [Bathroom mid].off() (26ms)
+225ms ║║Executed virtual command [Bathroom mid].setSwitch (29ms)
+258ms ║║Executed physical command [Bathroom right].off() (26ms)
+259ms ║║Executed virtual command [Bathroom right].setSwitch (30ms)
+264ms ║╚Execution stage complete. (135ms)
+269ms ╚Event processed successfully (269ms)
11/1/2021, 5:27:28 PM +710ms
+2ms ╔Received event [#5].motion = inactive with a delay of 84ms
+77ms ║RunTime Analysis CS > 20ms > PS > 6ms > PE > 50ms > CE
+79ms ║Runtime (40470 bytes) successfully initialized in 6ms (v0.3.113.20210203) (76ms)
+80ms ║╔Execution stage started
+86ms ║║Comparison (enum) inactive changes = true (1ms)
+87ms ║║Condition #18 evaluated true (3ms)
+88ms ║║Condition group #1 evaluated true (state did not change) (4ms)
+94ms ║║Comparison (enum) inactive is (string) active = false (1ms)
+95ms ║║Cancelling condition #4’s schedules…
+96ms ║║Condition #4 evaluated false (6ms)
+97ms ║║Cancelling condition #3’s schedules…
+98ms ║║Condition group #3 evaluated false (state changed) (8ms)
+105ms ║║Comparison (enum) inactive stays (string) inactive = true (1ms)
+107ms ║║Condition #6 evaluated false (7ms)
+108ms ║║Condition group #5 evaluated false (state did not change) (8ms)
+111ms ║╚Execution stage complete. (30ms)
+112ms ║Setting up scheduled job for Mon, Nov 1 2021 @ 5:30:11 PM CDT (in 162s)
+120ms ╚Event processed successfully (120ms)
11/1/2021, 5:25:13 PM +527ms
+1ms ╔Received event [#5].motion = active with a delay of 61ms
+75ms ║RunTime Analysis CS > 18ms > PS > 3ms > PE > 54ms > CE
+78ms ║Runtime (40472 bytes) successfully initialized in 3ms (v0.3.113.20210203) (75ms)
+79ms ║╔Execution stage started
+86ms ║║Comparison (enum) active changes = true (1ms)
+87ms ║║Condition #18 evaluated true (4ms)
+88ms ║║Condition group #1 evaluated true (state did not change) (5ms)
+95ms ║║Comparison (enum) active is (string) active = true (2ms)
+97ms ║║Cancelling condition #4’s schedules…
+98ms ║║Condition #4 evaluated true (6ms)
+99ms ║║Cancelling condition #3’s schedules…
+100ms ║║Condition group #3 evaluated true (state changed) (9ms)
+113ms ║║Comparison (time) 62713629 is_between (time) 14400000 … (time) 72000000 = true (9ms)
+115ms ║║Time restriction check passed
+116ms ║║Condition #10 evaluated true (14ms)
+118ms ║║Condition group #9 evaluated true (state did not change) (15ms)
+120ms ║║Cancelling statement #16’s schedules…
+129ms ║║Executed physical command [Bathroom left].setColorTemperature([5000]) (3ms)
+130ms ║║Executed [Bathroom left].setColorTemperature (5ms)
+138ms ║║Executed physical command [Bathroom mid].setColorTemperature([5000]) (4ms)
+139ms ║║Executed [Bathroom mid].setColorTemperature (6ms)
+144ms ║║Executed physical command [Bathroom right].setColorTemperature([5000]) (3ms)
+145ms ║║Executed [Bathroom right].setColorTemperature (5ms)
+162ms ║║Executed physical command [Bathroom left].setLevel([100]) (13ms)
+163ms ║║Executed [Bathroom left].setLevel (14ms)
+177ms ║║Executed physical command [Bathroom mid].setLevel([100]) (12ms)
+178ms ║║Executed [Bathroom mid].setLevel (13ms)
+192ms ║║Executed physical command [Bathroom right].setLevel([100]) (11ms)
+193ms ║║Executed [Bathroom right].setLevel (13ms)
+197ms ║╚Execution stage complete. (119ms)
+199ms ║Setting up scheduled job for Mon, Nov 1 2021 @ 5:30:11 PM CDT (in 297s)
+210ms ╚Event processed successfully (209ms)
11/1/2021, 5:25:10 PM +903ms
+2ms ╔Received event [#5].motion = inactive with a delay of 84ms
+80ms ║RunTime Analysis CS > 21ms > PS > 5ms > PE > 53ms > CE
+82ms ║Runtime (40468 bytes) successfully initialized in 5ms (v0.3.113.20210203) (80ms)
+83ms ║╔Execution stage started
+90ms ║║Comparison (enum) inactive changes = true (0ms)
+91ms ║║Condition #18 evaluated true (4ms)
+92ms ║║Condition group #1 evaluated true (state did not change) (5ms)
+98ms ║║Comparison (enum) inactive is (string) active = false (1ms)
+99ms ║║Cancelling condition #4’s schedules…
+100ms ║║Condition #4 evaluated false (6ms)
+101ms ║║Cancelling condition #3’s schedules…
+102ms ║║Condition group #3 evaluated false (state changed) (8ms)
+109ms ║║Comparison (enum) inactive stays (string) inactive = true (2ms)
+111ms ║║Adding a timed trigger schedule for condition 6
+113ms ║║Cancelling condition #6’s schedules…
+114ms ║║Condition #6 evaluated false (10ms)
+115ms ║║Cancelling condition #5’s schedules…
+116ms ║║Condition group #5 evaluated false (state changed) (12ms)
+119ms ║╚Execution stage complete. (36ms)
+121ms ║Setting up scheduled job for Mon, Nov 1 2021 @ 5:30:11 PM CDT (in 299s)
+129ms ╚Event processed successfully (129ms)
11/1/2021, 5:23:22 PM +133ms
+0ms ╔Received event [Home].time = 1635805403213 with a delay of -1081ms
+84ms ║RunTime Analysis CS > 21ms > PS > 5ms > PE > 58ms > CE
+86ms ║Runtime (40478 bytes) successfully initialized in 5ms (v0.3.113.20210203) (85ms)
+87ms ║╔Execution stage started
+107ms ║║Cancelling condition #6’s schedules…
+108ms ║║Condition #6 evaluated true (1ms)
+109ms ║║Cancelling condition #5’s schedules…
+110ms ║║Condition group #5 evaluated true (state changed) (4ms)
+112ms ║║Cancelling statement #7’s schedules…
+130ms ║║Executed physical command [Bathroom left].off() (13ms)
+131ms ║║Executed virtual command [Bathroom left].setSwitch (14ms)
+147ms ║║Executed physical command [Bathroom mid].off() (12ms)
+148ms ║║Executed virtual command [Bathroom mid].setSwitch (14ms)
+163ms ║║Executed physical command [Bathroom right].off() (13ms)
+164ms ║║Executed virtual command [Bathroom right].setSwitch (13ms)
+167ms ║╚Execution stage complete. (80ms)
+173ms ╚Event processed successfully (174ms)
11/1/2021, 5:22:15 PM +24ms
+0ms ╔Received event [#5].motion = active with a delay of 63ms
+68ms ║RunTime Analysis CS > 16ms > PS > 4ms > PE > 49ms > CE
+71ms ║Runtime (40472 bytes) successfully initialized in 4ms (v0.3.113.20210203) (70ms)
+72ms ║╔Execution stage started
+79ms ║║Comparison (enum) active changes = true (0ms)
+80ms ║║Condition #18 evaluated true (4ms)
+81ms ║║Condition group #1 evaluated true (state did not change) (5ms)
+87ms ║║Comparison (enum) active is (string) active = true (1ms)
+89ms ║║Cancelling condition #4’s schedules…
+90ms ║║Condition #4 evaluated true (7ms)
+91ms ║║Cancelling condition #3’s schedules…
+92ms ║║Condition group #3 evaluated true (state changed) (9ms)
+105ms ║║Comparison (time) 62535119 is_between (time) 14400000 … (time) 72000000 = true (8ms)
+106ms ║║Time restriction check passed
+108ms ║║Condition #10 evaluated true (14ms)
+109ms ║║Condition group #9 evaluated true (state did not change) (15ms)
+111ms ║║Cancelling statement #16’s schedules…
+120ms ║║Executed physical command [Bathroom left].setColorTemperature([5000]) (3ms)
+121ms ║║Executed [Bathroom left].setColorTemperature (5ms)
+127ms ║║Executed physical command [Bathroom mid].setColorTemperature([5000]) (3ms)
+128ms ║║Executed [Bathroom mid].setColorTemperature (5ms)
+136ms ║║Executed physical command [Bathroom right].setColorTemperature([5000]) (5ms)
+137ms ║║Executed [Bathroom right].setColorTemperature (6ms)
+153ms ║║Executed physical command [Bathroom left].setLevel([100]) (12ms)
+154ms ║║Executed [Bathroom left].setLevel (14ms)
+169ms ║║Executed physical command [Bathroom mid].setLevel([100]) (12ms)
+171ms ║║Executed [Bathroom mid].setLevel (14ms)
+186ms ║║Executed physical command [Bathroom right].setLevel([100]) (13ms)
+187ms ║║Executed [Bathroom right].setLevel (15ms)
+191ms ║╚Execution stage complete. (120ms)
+192ms ║Setting up scheduled job for Mon, Nov 1 2021 @ 5:23:23 PM CDT (in 67s)
+206ms ╚Event processed successfully (206ms)
11/1/2021, 5:21:30 PM +498ms
+1ms ╔Received event [#5].motion = inactive with a delay of 75ms
+71ms ║RunTime Analysis CS > 16ms > PS > 4ms > PE > 50ms > CE
+73ms ║Runtime (40470 bytes) successfully initialized in 4ms (v0.3.113.20210203) (72ms)
+74ms ║╔Execution stage started
+81ms ║║Comparison (enum) inactive changes = true (1ms)
+82ms ║║Condition #18 evaluated true (3ms)
+83ms ║║Condition group #1 evaluated true (state did not change) (5ms)
+90ms ║║Comparison (enum) inactive is (string) active = false (1ms)
+91ms ║║Cancelling condition #4’s schedules…
+92ms ║║Condition #4 evaluated false (6ms)
+93ms ║║Cancelling condition #3’s schedules…
+94ms ║║Condition group #3 evaluated false (state changed) (9ms)
+101ms ║║Comparison (enum) inactive stays (string) inactive = true (2ms)
+103ms ║║Condition #6 evaluated false (7ms)
+105ms ║║Condition group #5 evaluated false (state did not change) (8ms)
+108ms ║╚Execution stage complete. (33ms)
+109ms ║Setting up scheduled job for Mon, Nov 1 2021 @ 5:23:23 PM CDT (in 112s)
+120ms ╚Event processed successfully (120ms)
11/1/2021, 5:18:25 PM +411ms
+2ms ╔Received event [#5].motion = active with a delay of 80ms
+83ms ║RunTime Analysis CS > 24ms > PS > 6ms > PE > 52ms > CE
+85ms ║Runtime (40472 bytes) successfully initialized in 6ms (v0.3.113.20210203) (83ms)
+86ms ║╔Execution stage started
+92ms ║║Comparison (enum) active changes = true (0ms)
+94ms ║║Condition #18 evaluated true (3ms)
+95ms ║║Condition group #1 evaluated true (state did not change) (4ms)
+101ms ║║Comparison (enum) active is (string) active = true (1ms)
+102ms ║║Cancelling condition #4’s schedules…
+103ms ║║Condition #4 evaluated true (6ms)
+104ms ║║Cancelling condition #3’s schedules…
+105ms ║║Condition group #3 evaluated true (state changed) (9ms)
+118ms ║║Comparison (time) 62305519 is_between (time) 14400000 … (time) 72000000 = true (8ms)
+119ms ║║Time restriction check passed
+121ms ║║Condition #10 evaluated true (13ms)
+122ms ║║Condition group #9 evaluated true (state did not change) (14ms)
+124ms ║║Cancelling statement #16’s schedules…
+141ms ║║Executed physical command [Bathroom left].setColorTemperature([5000]) (9ms)
+142ms ║║Executed [Bathroom left].setColorTemperature (10ms)
+153ms ║║Executed physical command [Bathroom mid].setColorTemperature([5000]) (6ms)
+154ms ║║Executed [Bathroom mid].setColorTemperature (8ms)
+164ms ║║Executed physical command [Bathroom right].setColorTemperature([5000]) (6ms)
+165ms ║║Executed [Bathroom right].setColorTemperature (8ms)
+191ms ║║Executed physical command [Bathroom left].setLevel([100]) (19ms)
+192ms ║║Executed [Bathroom left].setLevel (20ms)
+230ms ║║Executed physical command [Bathroom mid].setLevel([100]) (34ms)
+231ms ║║Executed [Bathroom mid].setLevel (36ms)
+257ms ║║Executed physical command [Bathroom right].setLevel([100]) (22ms)
+258ms ║║Executed [Bathroom right].setLevel (23ms)
+262ms ║╚Execution stage complete. (176ms)
+263ms ║Setting up scheduled job for Mon, Nov 1 2021 @ 5:23:23 PM CDT (in 297s)
+273ms ╚Event processed successfully (272ms)
11/1/2021, 5:18:23 PM +88ms
+0ms ╔Received event [#5].motion = inactive with a delay of 89ms
+91ms ║RunTime Analysis CS > 17ms > PS > 5ms > PE > 70ms > CE
+94ms ║Runtime (40468 bytes) successfully initialized in 5ms (v0.3.113.20210203) (92ms)
+94ms ║╔Execution stage started
+101ms ║║Comparison (enum) inactive changes = true (1ms)
+103ms ║║Condition #18 evaluated true (3ms)
+104ms ║║Condition group #1 evaluated true (state did not change) (5ms)
+110ms ║║Comparison (enum) inactive is (string) active = false (2ms)
+111ms ║║Cancelling condition #4’s schedules…
+112ms ║║Condition #4 evaluated false (6ms)
+113ms ║║Cancelling condition #3’s schedules…
+114ms ║║Condition group #3 evaluated false (state changed) (8ms)
+122ms ║║Comparison (enum) inactive stays (string) inactive = true (2ms)
+124ms ║║Adding a timed trigger schedule for condition 6
+127ms ║║Cancelling condition #6’s schedules…
+128ms ║║Condition #6 evaluated false (10ms)
+129ms ║║Cancelling condition #5’s schedules…
+130ms ║║Condition group #5 evaluated false (state changed) (14ms)
+133ms ║╚Execution stage complete. (39ms)
+134ms ║Setting up scheduled job for Mon, Nov 1 2021 @ 5:23:23 PM CDT (in 299s)
+143ms ╚Event processed successfully (143ms)
11/1/2021, 5:10:14 PM +998ms
+2ms ╔Received event [#5].motion = active with a delay of 82ms
+88ms ║RunTime Analysis CS > 26ms > PS > 5ms > PE > 57ms > CE
+91ms ║Runtime (40470 bytes) successfully initialized in 5ms (v0.3.113.20210203) (88ms)
+92ms ║╔Execution stage started
+99ms ║║Comparison (enum) active changes = true (1ms)
+101ms ║║Condition #18 evaluated true (3ms)
+102ms ║║Condition group #1 evaluated true (state did not change) (6ms)
+109ms ║║Comparison (enum) active is (string) active = true (2ms)
+111ms ║║Cancelling condition #4’s schedules…
+112ms ║║Condition #4 evaluated true (8ms)
+114ms ║║Cancelling condition #3’s schedules…
+115ms ║║Condition group #3 evaluated true (state changed) (11ms)
+132ms ║║Comparison (time) 61815116 is_between (time) 14400000 … (time) 72000000 = true (11ms)
+133ms ║║Time restriction check passed
+135ms ║║Condition #10 evaluated true (17ms)
+136ms ║║Condition group #9 evaluated true (state did not change) (18ms)
+139ms ║║Cancelling statement #16’s schedules…
+156ms ║║Executed physical command [Bathroom left].setColorTemperature([5000]) (10ms)
+157ms ║║Executed [Bathroom left].setColorTemperature (12ms)
+171ms ║║Executed physical command [Bathroom mid].setColorTemperature([5000]) (9ms)
+172ms ║║Executed [Bathroom mid].setColorTemperature (11ms)
+183ms ║║Executed physical command [Bathroom right].setColorTemperature([5000]) (7ms)
+184ms ║║Executed [Bathroom right].setColorTemperature (9ms)
+210ms ║║Executed physical command [Bathroom left].setLevel([100]) (19ms)
+211ms ║║Executed [Bathroom left].setLevel (22ms)
+234ms ║║Executed physical command [Bathroom mid].setLevel([100]) (19ms)
+235ms ║║Executed [Bathroom mid].setLevel (21ms)
+259ms ║║Executed physical command [Bathroom right].setLevel([100]) (20ms)
+260ms ║║Executed [Bathroom right].setLevel (21ms)
+263ms ║╚Execution stage complete. (171ms)
+265ms ╚Event processed successfully (264ms)Preformatted text

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


#2

When using stays you should not nest these in commands that only run some states

Ie stays needs to be crossed on every execution

There are other threads on stays in this forum


#3

Thanks for the advice. I’ll head over and see what I can figure out about a stay. Thanks again for the lead.


#4

I’ll translate your logs for you.

5:10:14 PM +998ms
The piston is processing a motion active event and turns the lights on.

5:18:23 PM +88ms
The piston is processing a motion inactive event.
At +122ms the stays condition is reached. The actual comparison being evaluated at this point is ‘is motion inactive’ which is why you see true reported.
At +124ms a ‘timed trigger’ schedule is set (‘timed trigger’ is an alternative name for stays). This is a timer to wake up the piston in five minutes.
At +130ms you can see that the if condition has actually returned false and the piston goes on to exit. This is a quirk of stays. It always immediately returns false when evaluated in this way.
You can see the schedule has been set (4 m 59 s to go).

5:18:25 PM +411ms
Another motion active event so the lights are turned on (again). The piston doesn’t evaluate the stays condition again so as far as that is concerned the motion is still inactive and the schedule is still active (4 m 57 s to go).

5:21:30 PM +498ms
Another motion inactive event which falls through to the stays condition. The stays sees the motion is inactive and it doesn’t know it went active so it leaves the schedule unchanged (1 m 52 s to go).

5:22:15 PM +24ms
Another motion active event so the lights are on again. The stays condition isn’t reached to the schedule is still running (67s to go).

5:23:22 PM +133ms
A timer event received (about a second early). This is the one the stays scheduled five minutes ago. The piston wakes up and fast forwards to the stays condition and this time true is returned so the lights turn off.

5:25:10 PM +903ms
A motion inactive event is received. The piston falls through to stays, sets up another run for five minutes time and exits.

And so it continues …

Although the actual evaluation it does is the same as a condition, stays is classed as a trigger. As is generally the case with triggers, they need to be evaluated when the trigger event occurs. So the stays must be evaluated whenever there is a motion event, regardless of whether it is active or inactive. You will see the same sort of thing with changes. What counts is what the trigger condition actually evaluates.

The cure in this case is to lose the else at line 44 and just have ‘if motion active’ and ‘if motion stays inactive’ blocks. You’ll find the piston will still respond to the timers set up by the stays but will know not to do anything because it has ‘cancelled’ them.