What’s the functional difference between “If Switch STAYS AWAY from OFF”, versus “If Switch STAYS ON”? Any difference at all?
I have a piston that has several triggers for various things. In one section I have code that says:
If Switch Stays Away from Off for more than 15 minutes then
send notification Unit has been running for {formatDuration(age([My Switch : switch]), true, ‘m’)} and is still on!
end if
This generally works. I’ll get messages like “Unit has been running for 20 minutes and still on!” which is good. Because of “age(x)” which is what I want.
However sometimes it says “Unit has been running for 0 minutes and still on!”. In this case, the switch has actually turned OFF but for some reason, the IF statement still executes as true, and age(x) then of course returns 0 and when I look at the Things list I see every time that it is indeed off even though the IF statement passed as true. My goal is to update this logic so that it only sends me the message while the switch is still ON. I’m uncertain why this code sometimes runs once the switch has turned off…Its sort of like a race condition, but not really a true race as in microsecond but more like the sensor that I use to control the on/off status of the switch only updates once every 4 minutes.
Any ideas what is going on and how I can adjust my logic to fix it? Thanks!