If vs. Every execution


#1

An event (If statment) causes all statements in the piston to be evaluated when the event occurs.

Switch 1 and Dimmer 4 both toggle whenever Dimmer 6 changes.


I’ve just discovered that a timer (Every statement) in a piston only causes that statement in the piston to execute when the timer goes off.

Switch 1 is toggled every minute. Dimmer 4 never changes.

This is a bit of a surprise to me. I hope the information is helpful to others.


#4

I’m not actually asking for help here, just documenting observed behavior. I have found statements outside an event-related If statements and timer-related Every statements to be useful in some of my pistons. The examples are simplified and so don’t demonstrate this usefulness. It was a surprise to me that these are evaluated in the event case but not in the timer case.


#5

FWIW I just found this workaround that treats a daily timer like an event


#6

Add an ‘every’ block or an ‘on events’ block to it and it gets even more interesting.

Pistons are event handlers. They only run in response to events. For example, if you press the ‘Test’ button an event gets generated. Usually the piston starts executing from the top and works its way through like a script but certain blocks like ‘every’ cause it to operate outside the normal flow.


#7

The two images have been corrected now in the original post.
(Great concise examples, @kvng :grin: … Moved to the “Example Pistons” category)