Help with piston - wait cancelling on next motion


#1

Hopefully this is the right thread, and sorry for being dense, but I cannot figure out the right way to do this. What happens is that the wait is cancelled the next time there is motion. What can I do to prevent the wait from being cancelled?


Motion Based Light EXCEPT when Manually turned On
#2

moved to piston design help category.


#3

It is probably canceling because of the motion sensor returning to inactive state. You have this piston set up in a rather peculiar way.

First you check for any changes from your motion sensor.

Then you look at if the time is between a certain window.

Check if this switch is off.

Check if the same switch is off again and for the last 5 seconds.

Then finally check if the same motion sensor is reporting as active.

You must have a motion sensor that is kind of slow to report changes otherwise you light might not ever come on.

A simple rewrite could help solve your issue.

If motion changes to active
And
Time is between xx and yy
And
Switch was off for at least 5 seconds
Then
Using switch
Turn on
End if
If motion changes to inactive
Then
Using switch
Wait xx time
Turn off
End if


#4

Set Task Cancellation Policy (TCP) to never.
Click on the WITH and then the settings cog.
Set TCP to never.
Also change the motion sensor to “is active”.


#6

Setting the TCP to never was the magic. Thanks, it’s working great now.

I know that structure was odd but I was using it to try to debug the problem. When I gave up and asked you experts for help, I just left it as I last had it. I am now back to the more efficient way of writing the conditions.

Thanks.