Wondering if I can create a rule that does the following.
Trigger = plug turns on
Starts first repeat while that ends when a condition is met
Starts the second repeat while that ends when condition is met
Keeps doing the first repeat/second repeat loop until a condition is met (e.g., switch turns off)
Main question I have is getting from step 3 (when the second repeat ends) back to the restart the first repeat and then go to the second repeat again, etc., and going through the two repeats until the switch turns off in step 4. Not sure how/if I can do that.
I suspect I may need to just create two separate rules w/one repeat in each, and have the first call the second and the second call back to the first to keep the two repeat while loops repeating until I want them to end.
While Switch is on
While first condition is on
First Actions
END-REPEAT
While Second Condition is on
Second Actions
END-REPEAT
END-REPEAT
If you want either of the repeats to end when the switch is turned off, then add that as a condition to those two as well as the initial one. Makes sense?
I think so - just don't see how the rule will "restart" at the first repeat after the second repeat ends. Is it going to restart at the first repeat if the switch is still on? The behavior at the end of the second repeat is what I'm not sure of.
Oh - just noticed that above is a nested repeat, which you aren't supported IIRC. So wouldn't work due to that.
Thanks, I'll take a look at that. I generally prefer to use the Repeat function since I already have some understanding of its working, but options are good!
The solution that @Sebastien posted would work, but for the problem of nested repeats. You can't nest repeats within a rule, but you can accomplish this with multiple rules, each with its own repeat. Logically nested repeats, if you will. For @Sebastien's example it would be possibly three rules.
Don't want to re-start the state machine discussion in this topic, but wanted to note that I am kind of intrigued by this approach for my automation, and may look into it. Thanks for the suggestion.
As Bruce notes, head over to below if you want to talk more about state machines in detail...