Second part of piston not firing sometimes


#1

1) Give a description of the problem
I have a piston that turns on my porch light when I come home based on presence, and turns off on a timer when either of the doors (front door, or porch door) are closed. The porch light also comes on when one of these doors is opened. Everything works as expected if I stay at home, lights comes on, turns off after 5 minutes when I close a door. Light comes on when I come home and presence changes to present etc.

This does not work when I leave my house (and presence changes to not present).

2) What is the expected behavior?
I expect the light to turn off after 5 minutes when I leave.

3) What is happening/not happening?
When I leave my house, and drive away (so change to no longer present), the light does not turn off - I assume this is because my presence is changing and somehow interrupting the timer.

4) Post a Green Snapshot of the piston!

5) Attach any logs

In the logs you can see the 5 minute timer being set, but when it triggers you can see the turn off aspect being skipped and not executed.

1/30/2018, 8:45:09 AM +392ms
+2ms	â•”Starting piston... (v0.2.102.20180116)
+282ms	â•‘â•”Subscribing to devices...
+314ms	â•‘â•‘Subscribing to Amy's iPhone.presence...
+329ms	â•‘â•‘Subscribing to Forrest.presence...
+341ms	â•‘â•‘Subscribing to Julie.presence...
+354ms	â•‘â•‘Subscribing to Front Door Multisensor.contact...
+366ms	â•‘â•‘Subscribing to Porch Multisensor.contact...
+472ms	â•‘â•‘Subscribing to Porch Light...
+472ms	║╚Finished subscribing (209ms)
+637ms	╚Piston successfully started (637ms)
1/30/2018, 8:32:17 AM +157ms
+1ms	â•”Received event [My Home].time = 1517301138657 with a delay of -1500ms
+194ms	â•‘Runtime (44146 bytes) successfully initialized in 55ms (v0.2.102.20180116) (192ms)
+196ms	â•‘â•”Execution stage started
+197ms	║╚Execution stage complete. (1ms)
+198ms	╚Event processed successfully (198ms)
1/30/2018, 8:30:44 AM +714ms
+1ms	â•”Received event [Julie].presence = not present with a delay of 316ms
+179ms	â•‘Runtime (44138 bytes) successfully initialized in 42ms (v0.2.102.20180116) (176ms)
+180ms	â•‘â•”Execution stage started
+224ms	║╚Execution stage complete. (45ms)
+226ms	╚Event processed successfully (226ms)
1/30/2018, 8:27:18 AM +427ms
+0ms	â•”Received event [Front Door Multisensor].contact = closed with a delay of 1060ms
+176ms	â•‘Runtime (44148 bytes) successfully initialized in 38ms (v0.2.102.20180116) (175ms)
+177ms	â•‘â•”Execution stage started
+229ms	â•‘â•‘Executed virtual command [Porch Light].wait (0ms)
+230ms	â•‘â•‘Requesting a wake up for Tue, Jan 30 2018 @ 8:32:18 AM GMT (in 300.0s)
+234ms	║╚Execution stage complete. (57ms)
+235ms	â•‘Setting up scheduled job for Tue, Jan 30 2018 @ 8:32:18 AM GMT (in 299.996s)
+244ms	╚Event processed successfully (244ms)
1/30/2018, 8:27:12 AM +719ms
+1ms	â•”Received event [Front Door Multisensor].contact = open with a delay of 1069ms
+190ms	â•‘Runtime (44148 bytes) successfully initialized in 52ms (v0.2.102.20180116) (188ms)
+191ms	â•‘â•”Execution stage started
+285ms	║╚Execution stage complete. (94ms)
+286ms	╚Event processed successfully (286ms)
1/30/2018, 8:27:10 AM +588ms
+2ms	â•”Received event [Porch Multisensor].contact = closed with a delay of 1081ms
+192ms	â•‘Runtime (44143 bytes) successfully initialized in 61ms (v0.2.102.20180116) (190ms)
+193ms	â•‘â•”Execution stage started
+249ms	â•‘â•‘Executed virtual command [Porch Light].wait (0ms)
+250ms	â•‘â•‘Requesting a wake up for Tue, Jan 30 2018 @ 8:32:10 AM GMT (in 300.0s)
+255ms	║╚Execution stage complete. (62ms)
+256ms	â•‘Setting up scheduled job for Tue, Jan 30 2018 @ 8:32:10 AM GMT (in 299.996s)
+263ms	╚Event processed successfully (263ms)
1/30/2018, 8:27:07 AM +809ms
+1ms	â•”Received event [Porch Multisensor].contact = open with a delay of 1091ms
+343ms	â•‘Runtime (44144 bytes) successfully initialized in 192ms (v0.2.102.20180116) (341ms)
+344ms	â•‘â•”Execution stage started
+438ms	║╚Execution stage complete. (95ms)
+440ms	╚Event processed successfully (440ms)
1/30/2018, 7:40:26 AM +213ms
+1ms	â•”Received event [My Home].time = 1517298027208 with a delay of -995ms
+197ms	â•‘Runtime (44139 bytes) successfully initialized in 52ms (v0.2.102.20180116) (195ms)
+198ms	â•‘â•”Execution stage started
+199ms	║╚Execution stage complete. (1ms)
+200ms	╚Event processed successfully (200ms)
1/30/2018, 7:39:58 AM +568ms
+2ms	â•”Received event [Forrest].presence = not present with a delay of 124ms
+203ms	â•‘Runtime (44134 bytes) successfully initialized in 51ms (v0.2.102.20180116) (200ms)
+204ms	â•‘â•”Execution stage started
+247ms	║╚Execution stage complete. (44ms)
+248ms	╚Event processed successfully (248ms)
1/30/2018, 7:35:26 AM +843ms
+1ms	â•”Received event [Front Door Multisensor].contact = closed with a delay of 622ms
+309ms	â•‘Runtime (44141 bytes) successfully initialized in 45ms (v0.2.102.20180116) (307ms)
+310ms	â•‘â•”Execution stage started
+363ms	â•‘â•‘Executed virtual command [Porch Light].wait (0ms)
+364ms	â•‘â•‘Requesting a wake up for Tue, Jan 30 2018 @ 7:40:27 AM GMT (in 300.0s)
+369ms	║╚Execution stage complete. (59ms)
+370ms	â•‘Setting up scheduled job for Tue, Jan 30 2018 @ 7:40:27 AM GMT (in 299.995s)
+379ms	╚Event processed successfully (378ms)
1/30/2018, 7:35:21 AM +492ms
+1ms	â•”Received event [Front Door Multisensor].contact = open with a delay of 620ms
+177ms	â•‘Runtime (44141 bytes) successfully initialized in 39ms (v0.2.102.20180116) (175ms)
+178ms	â•‘â•”Execution stage started
+269ms	â•‘â•‘Executed [Porch Light].setLevel (6ms)
+278ms	â•‘â•‘Executed virtual command [Porch Light].setVariable (2ms)
+314ms	â•‘â•‘Executed virtual command [Porch Light].setState (0ms)
+329ms	║╚Execution stage complete. (151ms)
+330ms	╚Event processed successfully (330ms)
1/30/2018, 7:33:09 AM +329ms
+1ms	â•”Received event [Porch Multisensor].contact = closed with a delay of 547ms
+174ms	â•‘Runtime (44136 bytes) successfully initialized in 47ms (v0.2.102.20180116) (172ms)
+175ms	â•‘â•”Execution stage started
+228ms	â•‘â•‘Executed virtual command [Porch Light].wait (1ms)
+229ms	â•‘â•‘Requesting a wake up for Tue, Jan 30 2018 @ 7:38:09 AM GMT (in 300.0s)
+233ms	║╚Execution stage complete. (59ms)
+234ms	â•‘Setting up scheduled job for Tue, Jan 30 2018 @ 7:38:09 AM GMT (in 299.995s)
+244ms	╚Event processed successfully (244ms)
1/30/2018, 7:33:03 AM +281ms
+1ms	â•”Received event [Porch Multisensor].contact = open with a delay of 558ms
+188ms	â•‘Runtime (44136 bytes) successfully initialized in 47ms (v0.2.102.20180116) (187ms)
+190ms	â•‘â•”Execution stage started
+285ms	â•‘â•‘Executed [Porch Light].setLevel (6ms)
+294ms	â•‘â•‘Executed virtual command [Porch Light].setVariable (2ms)
+338ms	â•‘â•‘Executed virtual command [Porch Light].setState (1ms)
+353ms	║╚Execution stage complete. (164ms)
+354ms	╚Event processed successfully (354ms)
1/30/2018, 7:32:31 AM +419ms
+1ms	â•”Received event [Porch Multisensor].contact = closed with a delay of 555ms
+181ms	â•‘Runtime (44136 bytes) successfully initialized in 39ms (v0.2.102.20180116) (178ms)
+182ms	â•‘â•”Execution stage started
+233ms	â•‘â•‘Executed virtual command [Porch Light].wait (1ms)
+234ms	â•‘â•‘Requesting a wake up for Tue, Jan 30 2018 @ 7:37:31 AM GMT (in 300.0s)
+238ms	║╚Execution stage complete. (57ms)
+240ms	â•‘Setting up scheduled job for Tue, Jan 30 2018 @ 7:37:31 AM GMT (in 299.996s)
+247ms	╚Event processed successfully (246ms)
1/30/2018, 7:32:24 AM +520ms
+0ms	â•”Received event [Porch Multisensor].contact = open with a delay of 540ms
+172ms	â•‘Runtime (44122 bytes) successfully initialized in 46ms (v0.2.102.20180116) (170ms)
+173ms	â•‘â•”Execution stage started
+329ms	â•‘â•‘Executed [Porch Light].setLevel (71ms)
+337ms	â•‘â•‘Executed virtual command [Porch Light].setVariable (2ms)
+374ms	â•‘â•‘Executed virtual command [Porch Light].setState (1ms)
+387ms	║╚Execution stage complete. (215ms)
+388ms	╚Event processed successfully (388ms)
1/30/2018, 7:06:02 AM +122ms
+1ms	â•”Received event [My Home].time = 1517295963517 with a delay of -1395ms
+198ms	â•‘Runtime (44134 bytes) successfully initialized in 49ms (v0.2.102.20180116) (196ms)
+199ms	â•‘â•”Execution stage started
+420ms	â•‘â•‘Executed [Porch Light].off (198ms)
+452ms	â•‘â•‘Executed virtual command [Porch Light].setState (1ms)
+454ms	║╚Execution stage complete. (256ms)
+456ms	╚Event processed successfully (455ms)
1/30/2018, 7:01:03 AM +262ms
+2ms	â•”Received event [Porch Multisensor].contact = closed with a delay of 1054ms
+198ms	â•‘Runtime (44137 bytes) successfully initialized in 60ms (v0.2.102.20180116) (196ms)
+199ms	â•‘â•”Execution stage started
+254ms	â•‘â•‘Executed virtual command [Porch Light].wait (0ms)
+255ms	â•‘â•‘Requesting a wake up for Tue, Jan 30 2018 @ 7:06:03 AM GMT (in 300.0s)
+259ms	║╚Execution stage complete. (60ms)
+260ms	â•‘Setting up scheduled job for Tue, Jan 30 2018 @ 7:06:03 AM GMT (in 299.996s)
+270ms	╚Event processed successfully (270ms)
1/30/2018, 7:01:00 AM +448ms
+2ms	â•”Received event [Porch Multisensor].contact = open with a delay of 1068ms
+192ms	â•‘Runtime (44137 bytes) successfully initialized in 48ms (v0.2.102.20180116) (190ms)
+193ms	â•‘â•”Execution stage started
+289ms	â•‘â•‘Executed [Porch Light].setLevel (6ms)
+298ms	â•‘â•‘Executed virtual command [Porch Light].setVariable (3ms)
+335ms	â•‘â•‘Executed virtual command [Porch Light].setState (1ms)
+349ms	║╚Execution stage complete. (156ms)
+351ms	╚Event processed successfully (350ms)
1/30/2018, 7:00:59 AM +101ms
+1ms	â•”Received event [Front Door Multisensor].contact = closed with a delay of 1054ms
+203ms	â•‘Runtime (44142 bytes) successfully initialized in 58ms (v0.2.102.20180116) (201ms)
+204ms	â•‘â•”Execution stage started
+260ms	â•‘â•‘Executed virtual command [Porch Light].wait (1ms)
+261ms	â•‘â•‘Requesting a wake up for Tue, Jan 30 2018 @ 7:05:59 AM GMT (in 300.0s)
+265ms	║╚Execution stage complete. (61ms)
+267ms	â•‘Setting up scheduled job for Tue, Jan 30 2018 @ 7:05:59 AM GMT (in 299.995s)
+274ms	╚Event processed successfully (274ms)
1/30/2018, 7:00:52 AM +469ms
+1ms	â•”Received event [Porch Multisensor].contact = closed with a delay of 1054ms
+194ms	â•‘Runtime (44137 bytes) successfully initialized in 45ms (v0.2.102.20180116) (193ms)
+195ms	â•‘â•”Execution stage started
+256ms	â•‘â•‘Executed virtual command [Porch Light].wait (0ms)
+257ms	â•‘â•‘Requesting a wake up for Tue, Jan 30 2018 @ 7:05:52 AM GMT (in 300.0s)
+262ms	║╚Execution stage complete. (68ms)
+263ms	â•‘Setting up scheduled job for Tue, Jan 30 2018 @ 7:05:52 AM GMT (in 299.995s)
+270ms	╚Event processed successfully (271ms)
1/30/2018, 7:00:34 AM +10ms
+1ms	â•”Received event [Front Door Multisensor].contact = open with a delay of 1066ms
+193ms	â•‘Runtime (44142 bytes) successfully initialized in 52ms (v0.2.102.20180116) (190ms)
+194ms	â•‘â•”Execution stage started
+287ms	â•‘â•‘Executed [Porch Light].setLevel (6ms)
+296ms	â•‘â•‘Executed virtual command [Porch Light].setVariable (2ms)
+333ms	â•‘â•‘Executed virtual command [Porch Light].setState (0ms)
+346ms	║╚Execution stage complete. (153ms)
+347ms	╚Event processed successfully (347ms)
1/30/2018, 7:00:24 AM +160ms
+1ms	â•”Received event [Porch Multisensor].contact = open with a delay of 1110ms
+203ms	â•‘Runtime (44157 bytes) successfully initialized in 47ms (v0.2.102.20180116) (200ms)
+204ms	â•‘â•”Execution stage started
+492ms	â•‘â•‘Executed [Porch Light].setLevel (73ms)
+500ms	â•‘â•‘Executed virtual command [Porch Light].setVariable (2ms)
+539ms	â•‘â•‘Executed virtual command [Porch Light].setState (0ms)
+552ms	║╚Execution stage complete. (349ms)
+553ms	╚Event processed successfully (553ms)

#2

Try clicking on the WITH statement that contains a WAIT, then click on the gear cog at the bottom of the dialog box. Change your Task Cancelation Policy to “never cancel tasks”.

That should fix it but if not there’s one more thing we can do.


#3

Yeah, I agree with that. When you leave, the piston runs again because it gets an event from your presence, and then at that time the “changes to closed” is no longer true so the piston likely starts cancelling tasks (which is its default behavior). So you need to change the default on this one to get it to work.


#4

Hi - thanks for your responses!

I did think of that - but a question. If I did that, closed my door (timer starts) and then opened the door, the light would still turn off when the timer gets to 0, wouldn’t it? So I’d have to close and open the door again to turn the light back on?

I feel there should be another way to fix this, I just don’t have a very advanced understanding of the logic.

Thanks!

Edit:

Could I have it trigger if a door remains closed for 5 minutes? And set that to never cancel?


#5

Yeah, I think that would work better based on what you’re trying to achieve.

Sensors contact stays closed for 5 minutes
and
Light is on
(no wait needed)
Turn off light

The “stays” part will become true in 5 minutes…it won’t become true and then Wait 5 minutes. So you could open the door up again within that 5 minute period and it would as a result cancel the condition. So you don’t even need the never cancel with “stays”. it only becomes true at the end of 5 minutes.

I think you solved it…!


#6

Oh one more thing… Look into this function:

https://wiki.webcore.co/Functions#formatDateTime

Instead of all this:

Personally I use:

image


#7

Thanks for your help, and the link to the date/time functions!

Hopefully sorted now.

I’ll report back tomorrow…