# Adding a loop to scenes

**URL:** <https://community.gladysassistant.com/t/ajout-de-boucle-dans-les-scenes/9254>\
**Category:** Demandes livrées\
**Created:** [December 20, 2024, 7:28am UTC](https://community.gladysassistant.com/t/ajout-de-boucle-dans-les-scenes/9254 "2024-12-20T07:28:08Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![gaetanb76](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/gaetanb76/32/5911_2.png) [@gaetanb76](https://community.gladysassistant.com/u/gaetanb76)\
**Post date:** [December 20, 2024, 7:28am UTC](https://community.gladysassistant.com/t/ajout-de-boucle-dans-les-scenes/9254/1 "2024-12-20T07:28:08Z")

</div>

I would like to be able to repeat an action several times in a scene.  
For example, I set my water heater to forced mode and, so as not to forget to turn it off, I want to receive a message every 20 minutes for 2 hours.  
Rather than creating the action «&nbsp;wait 20 minutes&nbsp;» + «&nbsp;send a message&nbsp;» six times  
I would like

---

<div class="post-metadata">

**Author:** ![lmilcent](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/lmilcent/32/7023_2.png) [@lmilcent](https://community.gladysassistant.com/u/lmilcent)\
**Post date:** [December 21, 2024, 7:36pm UTC](https://community.gladysassistant.com/t/ajout-de-boucle-dans-les-scenes/9254/2 "2024-12-21T19:36:42Z")

</div>

Absolutely! Thanks for the suggestion, I’ve also had cases like that.

---

<div class="post-metadata">

**Author:** ![guim31](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/guim31/32/4840_2.png) [@guim31](https://community.gladysassistant.com/u/guim31)\
**Post date:** [December 24, 2024, 10:26am UTC](https://community.gladysassistant.com/t/ajout-de-boucle-dans-les-scenes/9254/3 "2024-12-24T10:26:39Z")

</div>

I also have the same issue with my alarm 👍

---

<div class="post-metadata">

**Author:** ![spenceur](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/spenceur/32/1961_2.png) [@spenceur](https://community.gladysassistant.com/u/spenceur)\
**Post date:** [December 28, 2024, 6:17am UTC](https://community.gladysassistant.com/t/ajout-de-boucle-dans-les-scenes/9254/4 "2024-12-28T06:17:56Z")

</div>

Wouldn’t it be the same request?

> [@Relancer la scène x fois](https://community.gladysassistant.com/t/relancer-la-scene-x-fois/9185?u=spenceur):
>
> Jai une scene qui me prévient sur mes enceintes si jai une fuites deau a mon ballon deau chaude. Mais madame ma fais une réflexion pertinente. Il faudrait que la scène se relance tout les y min. Alors attendre y min cest faisable. Mais relancer la meme scenes x fois ce nest pas possible non?

---

<div class="post-metadata">

**Author:** ![gaetanb76](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/gaetanb76/32/5911_2.png) [@gaetanb76](https://community.gladysassistant.com/u/gaetanb76)\
**Post date:** [December 29, 2024, 6:43pm UTC](https://community.gladysassistant.com/t/ajout-de-boucle-dans-les-scenes/9254/5 "2024-12-29T18:43:56Z")

</div>

It’s not the same purpose.  
In your case, you restart a scene.  
In my case, the loop is inside the scene.

---

<div class="post-metadata">

**Author:** ![gaetanb76](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/gaetanb76/32/5911_2.png) [@gaetanb76](https://community.gladysassistant.com/u/gaetanb76)\
**Post date:** [December 29, 2024, 6:48pm UTC](https://community.gladysassistant.com/t/ajout-de-boucle-dans-les-scenes/9254/6 "2024-12-29T18:48:04Z")

</div>

I think you should set as the trigger  
**Scheduled trigger**  
Type : Interval  
20 minutes

---

<div class="post-metadata">

**Author:** ![lmilcent](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/lmilcent/32/7023_2.png) [@lmilcent](https://community.gladysassistant.com/u/lmilcent)\
**Post date:** [December 30, 2024, 3:15pm UTC](https://community.gladysassistant.com/t/ajout-de-boucle-dans-les-scenes/9254/7 "2024-12-30T15:15:38Z")

</div>

For the «&nbsp;for 2h&nbsp;» part, you can create a scene that will «&nbsp;turn on&nbsp;» a fake MQTT device, then «&nbsp;turn it off&nbsp;» after 2 hours.

In parallel, you run your «&nbsp;every 20 min&nbsp;» scene only if your fake device is on.

---

<div class="post-metadata">

**Author:** ![cursor-bot](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/cursor-bot/32/22252_2.png) [@cursor-bot](https://community.gladysassistant.com/u/cursor-bot)\
**Post date:** [October 29, 2026, 10:41am UTC](https://community.gladysassistant.com/t/ajout-de-boucle-dans-les-scenes/9254/8 "2026-10-29T10:41:44Z")

</div>

Hi @gaetanb76!

The loop in a scene is the **While… Repeat…** block, since Gladys 4.86.

For the water heater and a reminder every 20 minutes for 2 hours:

1. You force the water heater to start.
2. You add **While…** with the condition that must remain true during the reminders.
3. In **Repeat…** : **Wait** 20 minutes, then **Send a message**.
4. You set the **maximum number of iterations** to 6.

Without a condition, the loop does not start. The limit is a safety feature: once reached, the loop stops and the rest of the scene executes. You no longer have to paste «&nbsp;wait + message&nbsp;» six times.

I’m filing this topic under «&nbsp;Delivered requests&nbsp;». If there’s still a case that doesn’t fit, open a new topic: it will be easier to follow.

---

<div class="post-metadata">

**Author:** ![cursor-bot](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/cursor-bot/32/22252_2.png) [@cursor-bot](https://community.gladysassistant.com/u/cursor-bot)\
**Post date:** [October 29, 2026, 10:41am UTC](https://community.gladysassistant.com/t/ajout-de-boucle-dans-les-scenes/9254/9 "2026-10-29T10:41:49Z")

</div>


