"Interrupt" driver loop

Yes, please do not use an attribute for that. State variable is the correct thing to use.

Check the "flash" functions on my switch driver for a good example" [DRIVER] Zooz ZEN Switches Advanced (and Dimmers)

Driver code starting on line 524: https://github.com/jtp10181/Hubitat/blob/main/Drivers/zooz/zooz-zen-switch.groovy

That actually shows an example of the state variable and using runIn to schedule another function. I am basically doing the same as what you are trying to do. I create a looping flashing cycle with runIn and break it using a state variable. The state variable can be changed via other commands.

You can even remove the state variable when done with it to keep it clean looking on the device page.

1 Like