Need help with simple piston which turns light off after a fixed interval of time


#1

1) Give a description of the problem
2) What is the expected behaviour?
The core premise is simple enough I think - turn on when motion is detected and no other lights are on, wait for 1 minute and turn off. The light turns on as expected based on all the conditions and restrictions in effect. However, it does not turn off after 1 mins.

3) What is happening/not happening?
From the logs I see that it asks for a wake up request after 1 minute. However, when the wakeup request is received, nothing happens.

**4) Post a Green Snapshot of the piston

5) Attach logs after turning logging level to Full

9/9/2020, 6:53:09 AM +118ms
+0ms ╔Received event [Home].time = 1599655990158 with a delay of -1040ms
+123ms ║RunTime Analysis CS > 27ms > PS > 52ms > PE > 44ms > CE
+126ms ║Runtime (41724 bytes) successfully initialized in 52ms (v0.3.110.20191009) (125ms)
+127ms ║╔Execution stage started
+128ms ║╚Execution stage complete. (1ms)
+129ms ╚Event processed successfully (129ms)

9/9/2020, 6:52:15 AM +89ms
+1ms ╔Received event [Front Door].contact = closed with a delay of 72ms
+94ms ║RunTime Analysis CS > 19ms > PS > 41ms > PE > 34ms > CE
+96ms ║Runtime (41727 bytes) successfully initialized in 41ms (v0.3.110.20191009) (94ms)
+97ms ║╔Execution stage started
+137ms ║║Comparison (time) 24735189 is_between (time) 1599700680000 .. (time) 1599654960000 = true (8ms)
+138ms ║║Time restriction check passed
+140ms ║║Condition #1 evaluated true (40ms)
+141ms ║║Condition group #null evaluated true (state did not change) (41ms)
+145ms ║║Comparison (enum) closed changes_to (string) open = false (0ms)
+147ms ║║Cancelling condition #3's schedules...
+147ms ║║Condition #3 evaluated false (5ms)
+150ms ║║Conditional ladder step failed due to a timeout
+151ms ║║Cancelling statement #9's schedules...
+152ms ║║Condition group #9 evaluated false (state did not change) (3ms)
+152ms ║║Cancelling condition #2's schedules...
+153ms ║║Condition group #2 evaluated false (state changed) (11ms)
+155ms ║╚Execution stage complete. (58ms)
+156ms ╚Event processed successfully (156ms)

9/9/2020, 6:52:09 AM +943ms
+1ms ╔Received event [Front Door].contact = open with a delay of 6117ms
+76ms ║RunTime Analysis CS > 14ms > PS > 32ms > PE > 30ms > CE
+79ms ║Runtime (41734 bytes) successfully initialized in 32ms (v0.3.110.20191009) (77ms)
+80ms ║╔Execution stage started
+114ms ║║Comparison (time) 24730026 is_between (time) 1599700680000 .. (time) 1599654960000 = true (8ms)
+115ms ║║Time restriction check passed
+117ms ║║Condition #1 evaluated true (34ms)
+118ms ║║Condition group #null evaluated true (state did not change) (35ms)
+122ms ║║Comparison (enum) open changes_to (string) open = true (1ms)
+123ms ║║Cancelling condition #3's schedules...
+124ms ║║Condition #3 evaluated true (5ms)
+125ms ║║Cancelling condition #2's schedules...
+126ms ║║Condition group #2 evaluated true (state changed) (7ms)
+160ms ║║Comparison (enum) off is (string) off = true (1ms)
+162ms ║║Comparison (enum) off is (string) off = true (1ms)
+164ms ║║Comparison (enum) off is (string) off = true (1ms)
+167ms ║║Comparison (enum) off is (string) off = true (1ms)
+169ms ║║Comparison (enum) off is (string) off = true (1ms)
+171ms ║║Comparison (enum) off is (string) off = true (1ms)
+173ms ║║Condition #13 evaluated true (44ms)
+174ms ║║Condition group #12 evaluated true (state did not change) (46ms)
+176ms ║║Cancelling statement #4's schedules...
+209ms ║║Executed physical command [Passage Light (Hallway)].setLevel([50]) (30ms)
+210ms ║║Executed [Passage Light (Hallway)].setLevel (32ms)
+213ms ║║Executed virtual command [Passage Light (Hallway)].wait (1ms)
+214ms ║║Requesting a wake up for Wed, Sep 9 2020 @ 6:53:10 AM MDT (in 60.0s)
+218ms ║╚Execution stage complete. (139ms)
+220ms ║Setting up scheduled job for Wed, Sep 9 2020 @ 6:53:10 AM MDT (in 59.996s)
+228ms ╚Event processed successfully (228ms)

#2

Hi, I’m not sure about all your conditions to switch the light on, they seem quite complex, but I assume they’re ok as the light comes on/

I suspect the turn off fails as the piston will be cancelled if any of the triggers occur again. To get round this you need to change the task cancellation to never on the with statement. Its available if you edit the with and then click the gear icon at the bottom


#3

Yeah, it’s a long-winded way of saying that turn the light at the entrance on only if it’s dark :confused:
Thanks for pointing me to the Task Cancellation Policy. I set it to never cancel and it worked.
I also found some more information about how TCP works here: How TCP is set to NEVER - when WAIT is not working in your piston