#Limit to the number of iterations of an Until loop

1 messages · Page 1 of 1 (latest)

thorn prawn
#

I have an automation that changes the colours of my outside lights over the Christmas period. It works well except that I can only change the colour every 2 seconds as there appears to a limit of 10,000 iterations for an Until loop. The lights come on at sunset which is about 8pm and I have them set to turn off at midnight so that is about 4 hours. If I set it for every 2 seconds then that is 30 iterations per minute x 60 minutes x 4 hours = 7200 iterations and it works. However, I would prefer the lights to change colour every second or even every half a second. Both of these settings work but it crashes when the loop count gets to 10,000. If set to 1 second then it crashes after 10,000/3600 which is only 2.77 hours and only 1.39 hours if set to 500ms.

Is there a way to increase the limit from 10,000? I'm sure it there to stop automations getting into infinite loops but that is not the case in this situation. I'd get away with 20,000 for the 1 second loops.

thorny island
#

Hi @thorn prawn,
No, but you can work around it.
Put the loop in a script, then call the script multiple times. Scale as needed.

#

Limit the number of iterations in each script so it doesn't count too big.

thorn prawn
#

OK thanks for the reply. The automation is based on a Blueprint so rather than play around with it myself I have mentioned the issue in the Blueprints Exchange. Hopefully the dev has some ideas.

visual lintel
#

what if you put a loop inside a loop

thorny island
#

Well if you had a script doing another loop then called the script in a loop, that is essentially what I was saying.

#

In the end it would be terribly resource heavy and something is bound to break.

thorn prawn
#

For now I have just set the colour change to happen every 1.5 seconds. That keeps the total iterations in 4 hours to just under the 10,000 limit. This is OK for 8pm to 12am for Christmas lights but the original intention of the Blueprint is for party lights. Most parties we have go longer than 4 hours so I’ll just have to reduce the colour change rate for those events.

I did see something about a Continue on Error flag. I wonder if that would work around it?

thorny island
#

So why can't you do an automation that starts the blueprint. That automation can watch one of the lights and if the light doesn't see a light turn-on for 10 seconds, or however you want to find the 'end' of the blueprints sequence, you just start it again. Maybe a tweak to the blueprint to start an helper toggle when it starts and shuts it off when it's done, then trigger your restart off of that.
Very simple tweaks could get you where you want to be.