My simple piston with delay resets the delay timer with every trigger


#1

1) Give a description of the problem
I have a piston that is triggered if an exterior door opens but nobody is home. Once the piston is triggered it waits 8 minutes before acting just in case someone recently arrived home but the presence hasn’t updated. The action won’t happen though until the trigger stops occurring. For example, my kid gets home from college and goes in and out several times unloading his car. The action finally happens 8 minutes after the last door open event.

Maybe I need to use “location stays away for 8 minutes” instead.

2) What is the expected behaviour?
I want the timer to start w/the first trigger and the action to happen 8 minutes after.

3) What is happening/not happening?
Pretty much stated this in #1 above.

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

5) Attach logs after turning logging level to Full
Sorry, no logs yet.

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


#2

I don’t like using 6 triggers in the same piston, but if you are willing to use a global variable, then this may do the trick. (Untested)

The boolean global variable is to prevent multiple triggers


Pro Tip:
I would normally make each of the three IFs above into their own piston. This keeps network traffic to a minimum, and allows for much more efficient growth. (future programming)

For example, there are many things that I want to happen when my location changes to X…

You can prevent multiple pistons from firing at the instant someone arrives home by moving a single line of code (line 24) into your current location piston.


#3

(everything Wcmore said) and when using WAIT you need to set TCP (Task Cancelling Policy) to NEVER so that the count down can continue.


#4

Thanks @WCmore and @ike2018 for the replies. I’ll need to tweak my approach to use the global variable via my “presence changed” piston.

I’ve never really considered minimizing network traffic. Is that referring to traffic within my SmartThings network or between webCoRE and my home or something else altogether? Is there a resource where I can study up on this topic?


#5

WebCoRE is rock solid… If a piston tells webCoRE to do X, then webCoRE reliably sends the command X. The issue that often occurs is, if there are too many things happening at once, then occasionally some of the commands will be lost in transit between SmartThings and the device. Because of this, I always try to program with only one trigger per piston (less commotion).

When you have multiple triggers in a piston, then any event will initiate the code to process from top to bottom. Similarly, when an event happens, I try to make sure only one piston is triggered. (for example, there is no need for a handful of pistons to fire when you arrive home)

The more thought we put into our programming, the snappier and more streamlined our SmartHome will become.


#6

Just a follow-up post to say the global variable approach worked. I alreay have a presence piston so I do the reset there. Thanks again.


#7

Glad to be able to help