Don't run again


#1

1) Give a description of the problem
I want a piston to run but don’t try to run again until it has completed. I have a motion sensor outside for my outside lights. When you cross it I want it to come on for a few minutes and then shut off. However, if you doubled back I don’t want it to run again. How do I make the piston run to completion before running again?


#2

I believe you can set the Task Cancellation Policy to never. That should cause a timer to countdown when the motion sensor detects motion, and the timer won’t reset during the countdown if motion is detected again.

^^ I believe that’s a correct statement… someone please correct me if I’m wrong.


#3

Setting TCP to never will prevent the current tasks from cancelling, but won’t prevent the piston from running again on a condition change and performing additional tasks. So in addition to setting the TCP to never, I would use a variable to prevent the piston from executing again. For example, if you want a two minute ‘reset’ window, you could use:

If Motion is active
and
$now < addMinutes(lastRun,2)
Then
set lastRun = $now
do stuff
End

Edit: You’ll need to initialize the lastRun variable, either by not including the “$now < addMinutes(lastRun,2)” the first time the piston is run, or by temporarily adding “set lastRun = $now” as an action statement outside of the IF statement and running the piston via the test button once.