I thought I found the perfect solution to my rule idea... I would expect the Repeat... Until loop to check the condition right before repeating again. What it actually does it check it as soon as the loop executes, then it waits (for an hour in my case) and runs again. This causes the loop to trigger one additional time after the conditions are met during the wait time. I want the loop to run at least once but then stop if the conditions change before the next run.
I could work around this with a delay in the loop but that is not going to be perfect. I can think of other convoluted band aids as well, but I really was hoping for this simple solution to work correctly.
May have to add a "wait for..." at the end of the loop and forcibly exit the rule, defeating the purpose of the "Until" check.
- Value changed which should end the loop
- Loop repeated anyway
- Conditions check again and loop ended
1 Like
Yes, that is the designed behavior.
Your case would be a good candidate for one of the other repeat formats if you have not already considered them -- or the low-tech solution of putting the actions you always want to run once outside the repeat (before it) and then using a "Repeat while," among other possibilities you may have already considered.
1 Like
Hmmm.. the Until seems pretty useless then as-is.
Why would you ever want it to check the conditions before the wait to repeat?
If you have a very short loop delay you may not even notice it ran an extra time so it may be harmless in that case but still wrong IMO.
I don't think any of those examples in the docs would solve this issue.
The only thing I can think of is having the actions duplicated before the loop (as you suggested) which I had originally considered before trying this.
The other way I think would work is having a Wait Until Expression and then if they are met Stop Repeating. If they are never met I assume it will just end that loop cycle and start it over?
Any of the examples using a simple "IF THEN" would work the same as the Until loop. The conditions are checked right away before the wait to repeat starts.
@bertabcd1234 This seems like it should work, assuming that if the Expression is never met when the loop repeat timer hits it will just start over and not execute the "Stop Repeating" after the wait?
(The Until is disabled for now until I verify this)
Without intending to hijack this thread, seems to me that there are other Repeat formats than those listed in the documentation that you linked to. Looks like the structure of Repeat options has changed.
There used to be a format of:
While (condition) Repeat every [time]
See the rule below, part of a suite of rules for flashing undercounter lights when an alarm condition exists for my Litter Robot 3. Has been working for at least 3 years, I believe:
Its still in there but it is called "Repeat While..." in the menu. Once added it shows up as "While ... Repeat Every" as you have shown.
This would not work for my rule because I need to execute at least once if the rule is triggered, regardless of the conditions in the loop. The trigger is slightly different from what causes the alert to repeat.
This is the annoy the family until they take care of the cat box so I don't have to rule (not my cats). They get one warning at 90% then if it hits 80% is gets more annoying.
2 Likes
Ok. An observation that I learned the hard way: you probably won't see it because your repeat loop is at one hour, mine is at 3 seconds. You are testing multiple conditions inside the repeat loop, but the Litter Robot litter level changes slowly.
That's why my loop tests a single global (hub) variable that other rules manage (bonnet removed, time to empty litter drawer, offline, etc). The load on the C-8 is now less than 9 when flashing, was previously up about 39 when lots of things were tested in the 3 second loop.
That's why my rule is structured as it is, with other supporting rules used to decide when to flash.
1 Like