1) Give a description of the problem
I am migrating from ST to HE and I guess I still suffer from phantom pains of things not happening on time all the time, so for most important actions I would like a piston to look like this
if switch is off then
switch.on()
end if
if switch.switch stays off for 1 minute then
notify “switch did not turn on - trying again”
switch.on()
end if
Now, as the piston is always executed manually, by the way of being called from other pistons, I thought of turning off the “subscribe to events” settings. However, apparently that also turns off the “stays for X minute” subscription". My concern is that if I turn subscription on, then the second if will execute whenever the switch stays off for 1 minute, whether it was triggered by this trigger or some other action.
I guess my question is about the mechanics of the piston execution. Here’s the workaround I though of
local var turningOn = true
if switch is off then
switch.on()
end if
only when turningOn is true and switch.switch is off
if switch.switch stays off for 1 minute then
notify “switch did not turn on - trying again”
switch.on()
end if
At this point I would expect the following behavior:
- if the piston was run from another piston, its execution started from the beginning, turningOn variable was set to true, and the whole thing executes properly.
- if the piston triggered by switch.switch staying off for 1 minute (not invoked by another piston), the turningOn is not set, so only when block will prevent any execution here.
Are these assumptions correct? Is there any easier way to get what I want here?
Thanks!