I miss the fear of creating a good ole fashion Infinite Loop - REPEAT / WHILE / UNTIL

But I can't seem to get there within the associated "repeat every" or "repeat n times" constraints.

I have a rule within which I have conditions or event waits in places that would cause the flow to exit the repeat loop, or otherwise change the state that the UNTIL is looking for to exit the repetition.

But I haven't yet gotten the "repeat every time" and "repeat n times" figured out to just let the thing run as it needs to and manage itself.

I first tried figuring out what the approximate cycle or repetition of minutes would be necessary for my use case but I found the rule was still sitting at a WAIT where it needed to be when along came the forced repeat cycle time that started things from the top again before it should have. Maybe this is because I had STOPPABLE set.

What's the trick, 24 hours on the time and 999 on the N ? Or do you let the loop keep incrementing the N value (if it can be after the REPEAT starts).

I'm finding your question hard to understand. Can you share a screenshot (or a least copy/paste) of the rule, ideally including all parts or at least the actions you're asking about, as well as a description of what you're trying to do?

Some things that may be helpful to know in case they are part of your question:

  • You can create a repeat that never stops until you make it. The "repeat n times option" is not required (only the repeat interval is).
  • A "wait" inside a repeat doesn't pause or stop the repeat itself -- the repeat interval alone determines when the contents inside the repeat start executing again.

Thanks for the reply.

This rule turns on a small AC unit on upon a selection of triggers, then waits for one of a few events ....one of which is a power drop into a range, ....that power drop into a specific range is due to the AC compressor going off and the unit continues to blow humid air off the coils....the REPEAT is all about shutting the unit down for a bit of a rest period and then firing it back up whence it goes back into cooling until the next time. Of course in the middle of all that are checks for conditions met to just shut it all down.

So comments aside about the malice I realize I may be bringing to the AC unit, I'd like to get some perspective on how to set the REPEAT because I don't trust that I have the settings right yet. The use of the variable "repeat" was a "belts & suspenders" effort to impart some control where I wasn't sure of the REPEAT statement's behavior.

Syntactically, that repeat looks fine; it should stop repeating once your repeat variable gets set to false, which looks like your intention. The 12-hour timeout on the wait inside, however, is a bit odd -- that's longer than your repeat interval, so unless one of the events you're waiting for happens first, it's going to go back to the beginning of the repeat before then anyway. (I'm honestly don't remember if a repeat starting over cancels waits inside, but I don't think so, and I'd recommend making any wait, delay, or timeout times less than the repeat interval in any case.)

Logically beyond that, I'm not sure exactly what everything else that is being looked at is supposed to do, but if it makes sense to you after a second look and it's still not working the way you expect, I'd suggest enabling all logging for the rule and taking a look at Logs, most likely Past Logs by the time you look, filtered to this particular rule so you can see what is happening when and make any adjustments that are needed.

Another approach you might consider is making the rule simpler by splitting out other parts into different rules. For example (unless you have a periodic trigger you want to keep), you can cancel timers such as repeats inside one rule from an action in another rule. Multiple simple rules are, in general, easier to troubleshoot (and write) than one larger, more complex rule, so this can often help as well.

Good luck!

Thanks for the ideas!

The 12 hour timeout was in case one the Wait conditions never occurred (due to a device failure for example) and the unit kept on for way longer than the part of the day it is needed for.

The rule simplification by parting-out has come up before. I think you are right that this would clean up the flow in any one rule (like subroutines in a way) but it's that "come back a year from now and try to remember the layers of associated rules" thing that brings on some hesitation there.

I've played with the Repeat setting a bit

|Action: Until (Variable repeat(true) = false(F) [FALSE]) (rule false, waiting for next)

And so I see.... the repeat will not happen until the next time whereas I just want it to proceed irrespective of trying to figure out the right time interval and repeats per interval.

I'm sure this has application the way it's designed....but previous searching on this general subject of repeats brings up a good number of folks scratching their heads.

Repeats need a defined repeat interval; they are not like "for" loops in imperative programming languages in this respect. This is an intentional choice, likely because such loops are not a good match for an event-based home automation system where if you're thinking of doing something like that, it's better to listen for the event instead and because doing so risks overwhelming the hub.

1 Like