How to create a Loop?

Hi, Is there a way to do some loop in Flow or Advanced flows? Couldn’t find a way to do it… Thanks to help.

Have you searched the App Store or the community forum about “Loop”?

I think it depends on your use case what you want to achieve. In general there are several ways to create a loop, just with flows without any additional apps, with timer apps, or with the Loops app:

You can also use transitions in

or

I do not think that recursive use of Flows (with Tag) is useful and I do not know, if it is possible at all.
But could be an interesting test.

I ran a test and recursive flows work. Unfortunately a flow cannot invoke itself. But you can create two flows, which invoke each other. And there is a strict limit of a bit more than 100 recursions. In my example 116 worked, 117 stopped.
Start-flow to initiate global variables and then run the main recursive flow with the start value:


Here is the main recursive flow for the sum:

As it cannot refer to itself it refers to an old test flow that I changed. I does not anything but referring back to the main recursive flow with the same tag.
Test mit Tag
There are better methods to add the numbers from 1 to X, but it is a good example how it works. You just have to use it carefully.

2 Likes

I learned a lot, thanks

This is a loop flow that I created some time ago, when there was no Loop app.
I have spotlights in some of our planters on our patio. Normally they switch on in the evening depending on the brightness and switch off again at a certain time. During Advent, however, they change color every 5 minutes (green, red, white). I implemented this with the Chronograph app and the stopwatch function. When the stopwatch starts, the color changes to red. When the stopwatch reaches 5 minutes, the color changes to green. At 10 minutes, the color changes to white. And at 15 minutes, the flow starts all over again with red.
This flow is generally started by the basic flow, which changes a yes/no variable when it is Advent time (query realized via the IcalCalender app).
So there are various ways to create a loop flow.

Happy flow crafting! :wink:

1 Like