Timer Triggers - Odd behaviour

triggers

#1

**1) I’ve been trying to use the “Stays away” trigger with a motion detector. This issue also occurs with “Stays On”

**2) I expect the piston to run from top to bottom when the trigger occurs.

**3) It seems to start where ever the condition is and run until the end of the piston.

You will notice on the screenshot how the trace only begins at line 60 and not running the lines preceding. This IF statement was only added to aid debugging. On a run not started by this trigger the piston runs end to end.

What is the expected behaviour?


#2

Any chance you can post the entire piston and logs? Right now I see the top two IF blocks don’t have a do command for both. And the last IF block with several IF blocks embedded is cut off so hard to know what is going on.


#3

I would not put too much faith in the blue lines. Each trigger will run thru the entire piston, top to bottom, and execute any commands not blocked by conditions.

To say this another way:
IF X CHANGES (lines 44-53) is false 99.999% of the time…

Also, if it were me, I’d put something at line 57 & 62…
(a log to console should suffice)


You can verify what’s really going on by setting your Log Level to Full.


#4

The ‘stays’ comparison is also known as a ‘timed trigger’. It behaves as a trigger in the sense that the piston will subscribe to the attributes it uses, but evaluates like a condition. So for example ‘stays on’ evaluates like ‘is on’.

The unique feature of ‘stays’ is that, if the comparison is true, it schedules a task to wake up the piston after whatever time period you specified, but also returns false immediately and continues with the piston.

As with a ‘wait’ the scheduled task gets cancelled if the piston runs again and the stays comparison is no longer true. If the scheduled task isn’t cancelled that means the ‘stays’ condition is still true, and so it resumes the piston where it had left off, returning true to the stays condition.

Your trace seems consistent with the piston resuming at the end of the ‘stays’ period.