Generally speaking, it is wise to keep timers or loops separate from spam pistons like you have above. (which could easily trigger
dozens of times each hour)
The temperature change (on line 69) creates endless triggers
which can cause issues with loops.
Also, be aware that when temp changes, and the piston fires, it may change the thermostat mode, which will execute the piston again from the top. This would encourage me to combine those two clusters of commands into one. IE:
IF Thermostat temp changes
Then
IF temp is less than X
Then
Set thermostat mode to whatever
Set variable {command} to whatever
END IF
IF temp is greater than Y
Then
Set thermostat mode to whatever
Set variable {command} to whatever
END IF
IF temp is inside of range X & Y
Then
Set thermostat mode to off
Set variable {command} to whatever
END IF
Execute piston with arguments
END IF
Notice the “Execute piston” command is inside the top IF, but outside all of the others.
(since all scenarios send this command)
This reduces clutter, streamlines execution, and prevents double triggers
back to back.