[Scene] "While", being able to create controlled loops

Discussed here: Associer un bouton +/- au slider de couleur ou luminosité - #16 par lmilcent

Description

Allow, in a scene, repeating an action until one or more criteria are met.

Example

Allow pressing a button to increase a bulb’s brightness step by step.

While: action = « brightness_move_up » and brightness < 100
Then:

  • Brightness

I’m resending this request because it’s exactly what I need for my IKEA buttons

Since it’s the most requested feature, I’ve started working on Fable 5!

His proposal:


Docker image:

ghcr.io/gladysassistant/gladys-preview:claude-scenes-controlled-loops-sceu7j

The PR:

What do you think?

I haven’t looked at the PR, but is the case « the condition is never met » handled? To avoid zombie scenes

There is a maximum number of iterations defined by the user (you can see it on the screenshot, by the way!)

Nice that you’re starting this dev :+1:

I suggest moving the ‹ max number of iterations › parameter to the top of the structure, so it doesn’t end up too far away if the ‹ repeat › block is a bit long…

Excellent comeback!

Fixed:

very well: but I see that in the triggering conditions there is the « OR », but we would especially need the « AND » (ex: pressing a button AND brightness < 100%)

To make « AND » conditions, just add a condition!

Indeed, I just found out that you can do ANDs on conditions! Thanks
We should make that clear in the docs!

Great feedback, I’m improving the block:

Perfect: at least it’s very clear and you can’t miss it!

Tested and approved, development will be included in the next version of Gladys :slight_smile:

I’m closing this post as the feature is available in Gladys Assistant 4.86: