Lights On When Someone Arrives


1) Give a description of the problem
I have an arrival piston that worked until I made a recent update and I’m not sure if I added the update correctly. Depending on the arrival time, the various lights have their status captured, turned on, and restored after a given time.
I recently added the IF Statement beginning at line 59. Now the lights do come on as expected, but they do not turn off which they previously did. I just changed the IF Statement at line 30 to Never Cancel, but I’m not sure if that is right as I have yet to test this change.

2) What is the expected behaviour?
All of the lights come on and return to their original state after the given time. However, the newly added part beginning at line 59 will turn on an additional light if a door is opened within 5 minutes of another door being opened.

3) What is happening/not happening?
The lights come on, but are not restoring to their previous state after the given time. More often that not, the previous state is off.

**4) Post a Green Snapshot of the piston![image|45x37]


‘followed within’ is buggy… try a workaround like:

contact sensor 3 changes to open
{age(contact sensor 4 : contact)} is less than 5 minutes


Thanks, I’ll give it a try. Should the Task Cancellation Policy for the primary IF Statement remain the same. Currently it is set to Never Cancel Task.


Yes, I would leave TCP to never cancel for that part


I’ve tried a few different combinations of the TCP, but each time the newly added IF Statement cancels the previous task.

5/13/2019, 10:57:33 AM +912ms
+1ms ╔Received event [vGarage Door].contact = open with a delay of 100ms
+167ms ║RunTime Analysis CS > 22ms > PS > 98ms > PE > 48ms > CE
+170ms ║Runtime (53246 bytes) successfully initialized in 98ms (v0.3.10a.20190223) (168ms)
+171ms ║╔Execution stage started
+197ms ║║Cancelling condition #6’s schedules…
+198ms ║║Condition #6 evaluated false (21ms)
+200ms ║║Cancelling condition #1’s schedules…
+201ms ║║Condition group #1 evaluated false (state changed) (24ms)
+205ms ║╚Execution stage complete. (33ms)
+206ms ╚Event processed successfully (206ms)
5/13/2019, 10:57:16 AM +831ms
+1ms ╔Received event [vPresence].presence = present with a delay of 161ms
+227ms ║RunTime Analysis CS > 21ms > PS > 128ms > PE > 78ms > CE
+230ms ║Runtime (53258 bytes) successfully initialized in 128ms (v0.3.10a.20190223) (228ms)
+231ms ║╔Execution stage started
+255ms ║║Comparison (enum) present changes_to (string) present = true (1ms)
+258ms ║║Cancelling condition #6’s schedules…
+259ms ║║Condition #6 evaluated true (22ms)
+261ms ║║Cancelling condition #1’s schedules…
+262ms ║║Condition group #1 evaluated true (state changed) (25ms)
+264ms ║║Cancelling statement #2’s schedules…
+273ms ║║Executed virtual command setVariable (2ms)
+288ms ║║Executed virtual command setAlarmSystemStatus (12ms)
+296ms ║║Comparison (string) Disarmed is (string) Armed/Stay = false (2ms)
+298ms ║║Condition #28 evaluated false (7ms)
+299ms ║║Condition group #25 evaluated false (state did not change) (8ms)
+323ms ║║Comparison (time) 39437134 is_not_between (time) 1557795780000 … (time) 1557743760000 = true (14ms)
+325ms ║║Time restriction check passed
+327ms ║║Condition #31 evaluated true (24ms)
+328ms ║║Condition group #30 evaluated true (state did not change) (26ms)
+331ms ║║Cancelling statement #8’s schedules…
+340ms ║║Executed virtual command [Front Porch Light].saveStateLocally (2ms)
+365ms ║║Executed physical command [Front Porch Light].on() (22ms)
+366ms ║║Executed [Front Porch Light].on (24ms)
+371ms ║║Executed virtual command [Front Porch Light].wait (0ms)
+372ms ║║Requesting a wake up for Mon, May 13 2019 @ 10:59:17 AM CDT (in 120.0s)
+378ms ║║Cancelling statement #13’s schedules…
+388ms ║║Executed virtual command [Living Room Lamp Wall].saveStateLocally (1ms)
+392ms ║║Executed virtual command [Living Room Lamp Window].saveStateLocally (2ms)
+412ms ║║Executed physical command [Living Room Lamp Wall].setLevel([25]) (16ms)
+414ms ║║Executed [Living Room Lamp Wall].setLevel (18ms)
+455ms ║║Executed physical command [Living Room Lamp Window].setLevel([25]) (39ms)
+456ms ║║Executed [Living Room Lamp Window].setLevel (41ms)
+468ms ║║Executed physical command [Living Room Lamp Wall].on() (9ms)
+469ms ║║Executed [Living Room Lamp Wall].on (12ms)
+475ms ║║Skipped execution of physical command [Living Room Lamp Window].on([]) because it would make no change to the device. (3ms)
+476ms ║║Executed [Living Room Lamp Window].on (5ms)
+480ms ║║Executed virtual command [Living Room Lamp Wall, Living Room Lamp Window].wait (1ms)
+482ms ║║Requesting a wake up for Mon, May 13 2019 @ 10:58:17 AM CDT (in 60.0s)
+487ms ║║Cancelling statement #19’s schedules…
+497ms ║║Executed virtual command [TV Lamp].saveStateLocally (2ms)
+1958ms ║║Executed physical command [TV Lamp].setLevel([75]) (1457ms)
+1960ms ║║Executed [TV Lamp].setLevel (1458ms)
+2734ms ║║Executed physical command [TV Lamp].setColorTemperature([3200]) (769ms)
+2735ms ║║Executed [TV Lamp].setColorTemperature (772ms)
+2740ms ║║Executed virtual command [TV Lamp].wait (0ms)
+2741ms ║║Requesting a wake up for Mon, May 13 2019 @ 10:58:19 AM CDT (in 60.0s)
+2762ms ║║Condition #54 evaluated false (13ms)
+2763ms ║║Condition group #53 evaluated false (state did not change) (15ms)
+2764ms ║║Condition group #52 evaluated false (state did not change) (17ms)
+2769ms ║╚Execution stage complete. (2538ms)
+2772ms ║Setting up scheduled job for Mon, May 13 2019 @ 10:58:17 AM CDT (in 57.712s), with 2 more jobs pending
+2779ms ╚Event processed successfully (2779ms)


The cancelled statement message in the log is for something else, just part of how pistons work, and the live ‘trace’ will looks like it has cancelled because it’s moved on to the next thing (so the timer disappears)… but ‘never cancel’ never cancels.

Have you actually waited the 15 minutes to see what happens?


I waited the full time. The latest piston is a copy and I change the wait time to 1 and 2 minutes for the lights to go off, but nothing happens.


Try making the with’s ‘never cancel’ instead of the if’s… didn’t notice that before