Trying to set up a Repeat Actions loop and want it to run n number of times. The problem is that I am forced to also enter a time for the Done with Action button to appear. So, instead of looping 5 times without delay, the loop takes 5 unnecessary seconds.
Same with Repeat while Condition. I would think that the Repeat Interval option should be disconnected from the Repeat n Times option.
I've never wanted the loop to run "immediately" again, so I always have made sure the time exceeds the time it takes for the lines inside the loop to complete (to ensure it doesn't try to kick off again while lines are still running). Tbh, I'm not sure if it would or not--but I know that kicking rules off multiple times in a row can cause issues.
All repeats are time based. Thatโs how it works. You can select one second. Imagine that without that you would lock up your hub, potentially in an infinite loop.
But if I choose Repeat 5 times, there would be no infinite loop. I would suggest the settings work as:
time based loop requires a number of times
number based loop shouldn't require a time. Time is "optional'. If time is entered, it would become #1.
I see a greater risk for an infinite loop with Repeat with Condition, if someone messes up and the condition doesn't change to break the loop. In that case, I would think the number of times would be required as a backstop. Still, I don't see why the time would be a required setting.
Well, not infinitely quickly but once the loop completes, start again without needing to wait. Aren't the steps executed in order, gets to the end of the Repeat, and then starts again? Or are all repeats executed simultaneously?
That explains it, then. I considered the Repeat more like a While or For in a scripting language like php or perl.
Thanks, but no thanks. It will remain the way it is.
You never said anything about your use case for this. In the past, every such stated use case turned out to be better served another way. This has been going on for years, and no one has showed a valid use case for what you are describing.
Oh, and by the way, if you put 10000 in for n repeats, you would lock up your hub for a long time. RM isn't going to police that. n can also be a variable, where the potential for damage goes way up.
Fair enough. It was just my suggestion. I should have said request, but either way, understood.
10,000 for repeats is way beyond me. I can't even begin to imagine how that would be used in home automation. My use case is very simple. I get a bunch of calendar events and some automation stuff happens. At the same time, a combined list gets sent to and stored in a device attribute which triggers a rule to do some reformatting and cleanup for sending a notification to the phone and/or email. HTML prettification was part of the goal, but that's not going to happen due to HE understandably stripping out tags for security purposes. So the more limited goal is the previous cleanup.
The rule doesn't know how many events are in the variable, and I discovered that each variable replacement step would only work on the first instance in the variable. So, each step was repeated 6 times for 5-6 possible events, just in case. 8 cleanup steps, repeated 6 times. It worked, but changes were difficult to maintain. Coming from a scripting background, it seemed a loop would simplify things.
I know other options are to write a driver, an app, or use webcore. Unfortunately, I am far from reaching that stage. I'm only at the "tinker with something that already exists and hope it doesn't break" stage.
For my use case, 6 second delay is not critical, so it's not a hill I would die on. If there is a simpler way to do the cleanup, I'm all ears.
A "Repeat 1 time" never completes (it executes the items inside the "Rep-EndRep" loop, but never continues after that.
I only found this as I was (happily) testing the "Command Retry" in lieu of my coded Repeat loops--before I totally upended my code, I was just going to change the loop to "one time only". My workaround was to stuff a "Stop Repeating" command at the end. Just wanted to mention it as a very minor issue.
If you don't want the 6 seconds, don't use Repeat at all. Just copy/paste the actions 5 times. Those actions will run back to back with no delay at all. None of the overhead of Repeat.
Part of my learning curve with Rule Machine was defeating my computer science courses understanding of how programming works. Rule Machine looked enough like a programming language at first. But I kept getting frustrated when looking for "how do they do this? Oh they don't. Try another way" Or "why don't they let me do this" Then finally, RTFM...