Trying to create a rule that basically runs a timer turning on/off an outlet every 20 minutes. The rule should be started by a virtual button and stopped by a second virtual button.
I have the rule starting with the 1st button fine, but it isn't looping. Not sure what I have wrong there.
Also can't figure out how to pause with the second button press.
Your repeat is malformed. The "Repeat" and "END-REP" lines need to enclose your block of actions to repeat. See: Rule 5.1 | Hubitat Documentation
For how to stop, that will be tricky since your trigger to start this rule is also the event you would need to make this stop. One easy solution is to toggle a variable with that button press, then check the state of that variable. So, your actions could be:
IF (Private Boolean true) THEN
Set Private Boolean False
Repeat every 0:40:00 (stoppable)
On: Kasa Outlet
Wait for event: elapsed time --> 0:20:00
Off: Kasa Outlet
END-REP
ELSE
Set Private Boolean True
Stop Repeating Actions
// maybe turn it on or off here if you want a specific end state?
END-IF
EDIT: I like the below idea too if you don't care about "triggering" this all exactly on the button press!
If you don't need the first cycle to start right when you push the button you can have a rule that runs every 20 minutes. For example, I have this simple rule:
Every 20 minutes it toggles an outlet. Then you can have your button toggle a boolean variable (ex: runActive). Then just add an if statement around the toggle.
if (runActive) then
toggle outlet
end if
From there you can make it more complex if desired.
Thank you both I'll try and see what works better.
Probably should have put a purpose. Tore my bicep tendon and having surgery next week. Want to use this to toggle the ice machine on and off, so I don't have to keep doing it manually.
Might be making it more complex then necessary. Looking to learn more about Hubitat automation and have some fun with a really crappy situation.