Im baffled how wait is supposed to work


#1

1) Give a description of the problem
I’m trying to learn how wait is supposed to work by taking the simplest possible piston and testing
2) What is the expected behaviour?
I expect to see the 120 second timer message

3) What is happening/not happening?
the timer is getting cancelled by the message from motion sensor going inactive - this doesn’t make sense because going ACTIVE is the trigger

4) Post a Green Snapshot of the pistonimage

5) Attach logs after turning logging level to Full
logs above


#2

This piston is subscribed to your sensor’s motion. This means when the motion changes in either direction (active or inactive) the piston runs top to bottom, and executes any code that is allowed by conditions.

In this case, the changing to inactive activates the piston again, but due to line 15, it does not run any of the code. It simply cancels the previous wait. This is normal, and usually preferred.

If, on the other hand, you want the remaining code to complete regardless of circumstances, then the WITH on line 17 can have Task Cancellation Policy set to Never.


#3

If it helps, here is the way I usually code for motion sensors:

IF Sensor's motion changes to active
Then
    Turn on light
END IF

IF Sensor's motion stays inactive for 120 seconds
Then
    Turn off light
END IF

This method turns on the light instantly, and keeps it on until the room is vacant for 2 minutes. (no wait required)