Relaunch the scene x times

I have a scene that notifies me on my speakers if I have a water leak at my hot water tank.
But my wife made a pertinent remark.
The scene would need to restart every y minutes.

So waiting y minutes is doable. But restarting the same scene x times isn’t possible, right?

When you put a condition on a sensor, it will always be true…
Example:

Thanks for this solution, but the goal is that I run it x times and not every time haha

You can make a counter that is incremented and that only triggers the scene if the counter is < X

  • Create a virtual device
  • Set to 0 by default in a scene
  • On each execution, set the device to the previous value + 1

Another scene triggers on the device’s new value if the value < 4 (for example) :slight_smile:

That’s a very clever solution… but it only makes sense to a developer’s brain! :sweat_smile:

After that, it doesn’t work.
As soon as we reset the virtual device to 0, we’ll fall back into the < x condition and restart the scene

Not necessarily, you can check that it’s < 4 AND different from zero

Right now I don’t see how to do an « and » in the triggers :thinking:
I can’t make conditions like counter != 0
Because when it gets reset to 0 I won’t enter this scene anymore

You can create 3 scenes:

Scene No. 1

Trigger: If balloon leaks

Actions:

  • Control a device, counter = 1

Scene No. 2

Trigger

Hi @spenceur!

You can repeat the alert as long as the leak lasts, without duplicating the scene. Since Gladys 4.86, the editor has the While… Repeat… block.

For the balloon:

  1. Trigger: the leak.
  2. While… block: the condition « the leak is still there ».
  3. In Repeat…: the message on the speakers, then Wait Y minutes.
  4. Maximum number of iterations: X, to stop even if the leak remains.

The condition is rechecked each time. An Get the last state action, placed before the condition, refreshes the value each time. When the leak disappears, the loop stops. If you reach X, only the loop stops: the actions placed after continue.

I’m moving this topic to « Delivered requests ». If there’s still a case that doesn’t fit, open a new topic: it’ll be easier to follow.