# Bug in the new delayed trigger

**URL:** <https://community.gladysassistant.com/t/defaut-dans-le-nouveau-declencheur-avec-delai/9225>\
**Category:** Configuration\
**Created:** [December 6, 2024, 7:54pm UTC](https://community.gladysassistant.com/t/defaut-dans-le-nouveau-declencheur-avec-delai/9225 "2024-12-06T19:54:22Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![StephaneB](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/stephaneb/32/15443_2.png) [@StephaneB](https://community.gladysassistant.com/u/StephaneB)\
**Post date:** [December 6, 2024, 7:54pm UTC](https://community.gladysassistant.com/t/defaut-dans-le-nouveau-declencheur-avec-delai/9225/1 "2024-12-06T19:54:22Z")

</div>

@pierre-gilles, I think I’ve spotted a bug in the delayed trigger: I enabled this ‹&nbsp;delay&nbsp;› option on a trigger, and it seems the other option ‹&nbsp;only if the threshold is exceeded&nbsp;› is no longer being taken into account correctly.

Specifically, I’m monitoring my fridge temperature so it doesn’t get too cold. I want Gladys to warn me if it goes below 0°, only if that lasts for more than 5 minutes, and without repeating the information for every subsequent measurement that is still below 0°.

So I have this as the trigger:

 ![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/3X/5/9/59e40b37196c79887193a009cf5856b72af345ce.png)

But I observe this in my alerts on Telegram:

 ![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/3X/0/2/0256536b07dcfe4c05e5071df3a01d9fda49a911.png)

And over the same period, here is the temperature curve:

 ![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/3X/2/5/25522c42aba14d4d64e8ed6e36f8bb2f7404e907.png)

The trigger should therefore have fired only once, at 18:37. But not the two following times.

Is my analysis correct?

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [December 9, 2024, 6:52am UTC](https://community.gladysassistant.com/t/defaut-dans-le-nouveau-declencheur-avec-delai/9225/2 "2024-12-09T06:52:39Z")

</div>

Indeed, that’s not normal 🙂

I’ve created a GitHub issue:

> <https://github.com/GladysAssistant/Gladys/issues/2183>
>
> https://community.gladysassistant.com/t/defaut-dans-le-nouveau-declencheur-avec-…delai/9225

I’ll get back to you as soon as I’ve had a chance to look; given my schedule it’ll probably be in January 2025! (busy end of year!)

---

<div class="post-metadata">

**Author:** ![StephaneB](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/stephaneb/32/15443_2.png) [@StephaneB](https://community.gladysassistant.com/u/StephaneB)\
**Post date:** [December 9, 2024, 7:05am UTC](https://community.gladysassistant.com/t/defaut-dans-le-nouveau-declencheur-avec-delai/9225/3 "2024-12-09T07:05:10Z")

</div>

OK thanks! It’s not critical, so it can wait a bit…

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [January 23, 2025, 12:38pm UTC](https://community.gladysassistant.com/t/defaut-dans-le-nouveau-declencheur-avec-delai/9225/4 "2025-01-23T12:38:42Z")

</div>

Hi @StephaneB 🙂

I’ve just run some tests, and the behavior seems correct to me. I can’t reproduce any faulty behavior.

In your case, since temperatures are hovering around 0°C, it’s possible that a value goes back to 0°C, then back to -0.1°C, which resets the process because the threshold has been crossed again.

Your messages cannot attest to the bug, because your messages are triggered with a «&nbsp;retrieve the last state&nbsp;» which itself is triggered after the 5-minute wait, so it’s not the same value as the one in the trigger.

If you want us to push the investigation further, you would need to extract from your database the actual values received by Gladys and replay the same scenario, but it’s up to you to tell me whether this is a behavior you continue to see or not 🙂

---

<div class="post-metadata">

**Author:** ![StephaneB](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/stephaneb/32/15443_2.png) [@StephaneB](https://community.gladysassistant.com/u/StephaneB)\
**Post date:** [January 23, 2025, 5:11pm UTC](https://community.gladysassistant.com/t/defaut-dans-le-nouveau-declencheur-avec-delai/9225/5 "2025-01-23T17:11:33Z")

</div>

Thanks for trying to reproduce it. I’ll take a closer look and get back to you.

---

<div class="post-metadata">

**Author:** ![StephaneB](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/stephaneb/32/15443_2.png) [@StephaneB](https://community.gladysassistant.com/u/StephaneB)\
**Post date:** [May 29, 2025, 10:44am UTC](https://community.gladysassistant.com/t/defaut-dans-le-nouveau-declencheur-avec-delai/9225/6 "2025-05-29T10:44:52Z")

</div>

@pierre-gilles,  
I came back across this issue that you hadn’t been able to reproduce. So in my view it is still present. My new situation may be easier to reproduce:

- In Gladys, I defined an MQTT device of type «&nbsp;switch&nbsp;».
- A Node-RED flow monitors my network every 5 minutes and sends «&nbsp;0&nbsp;» or «&nbsp;1&nbsp;» to the MQTT device, depending on the internet connection: absent or present
- In Gladys, a scene is supposed to trigger when the MQTT device goes to 0 and remains so for at least 12 minutes. Here is its config:

 ![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/3X/9/4/94f4c98bffee5f329d538e6e05c47d336927f909.png)

The issue, when the internet connection is lost and Node-RED therefore sends a «&nbsp;0&nbsp;» every 5 minutes, is the following:

- On the first «&nbsp;0&nbsp;» received, the scene detects the transition to OFF, and only notifies me 12 minutes later. That’s okay.
- but after those 12 minutes, a new «&nbsp;0&nbsp;» received restarts the trigger which activates the scene again 12 minutes later.
- So in practice, the scene triggers every 15 minutes (whereas only the first trigger matters to me)

With this context, can you reproduce it?

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [May 29, 2025, 11:00am UTC](https://community.gladysassistant.com/t/defaut-dans-le-nouveau-declencheur-avec-delai/9225/7 "2025-05-29T11:00:07Z")

</div>

Hi @StephaneB 🙂

I just ran a test with exactly the behavior you described to me (but reducing the wait time to 1 minute so it’s easier to see)

 ![Screenshot 2025-05-29 at 12.58.26](https://gladys-assistant-community.b-cdn.net/uploads/default/original/3X/1/d/1ddd7cefb67a448312d55c3decf42054814f3629.png)

 ![Screenshot 2025-05-29 at 12.58.43](https://gladys-assistant-community.b-cdn.net/uploads/default/original/3X/0/4/047bdf22e3cbf90a04a5523b021b55ea2fddaae3.png)

The behavior works perfectly for me, only one message received, 1 minute after the first 0 was received:

 ![Screenshot 2025-05-29 at 12.59.08](https://gladys-assistant-community.b-cdn.net/uploads/default/original/3X/2/b/2bda8eb5fff4f9b3fbd61e660f4214e4b4367b68.png)

In my opinion, on your side, the state returns to 1 between the two 0s.

You can investigate using the «&nbsp;graph&nbsp;» widget on a binary sensor to see when it goes from 0 to 1.

---

<div class="post-metadata">

**Author:** ![StephaneB](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/stephaneb/32/15443_2.png) [@StephaneB](https://community.gladysassistant.com/u/StephaneB)\
**Post date:** [May 29, 2025, 12:36pm UTC](https://community.gladysassistant.com/t/defaut-dans-le-nouveau-declencheur-avec-delai/9225/8 "2025-05-29T12:36:46Z")

</div>

Thanks for taking the time to test, @pierre-gilles. But I’m not sure we’re doing exactly the same test 😉.

I checked, and my device doesn’t switch back to 1 between two triggers. Since it’s a binary sensor, I’m certain of this thanks to the graph widget that lets you see the start and end of the ‹&nbsp;0&nbsp;› state.

I’ll try to clarify what’s happening on my side:

- before 1:00 PM: the MQTT device is at 1
- 1:00 PM: the MQTT device switches to 0. The scene does not trigger (but in the background it should start checking the 12-minute trigger delay). Behavior OK.
- 1:05 PM: the MQTT device receives ‹&nbsp;0&nbsp;› again. Nothing happens. Behavior OK
- 1:10 PM: the MQTT device receives ‹&nbsp;0&nbsp;› again. Nothing happens. Behavior OK
- 1:12 PM: the MQTT device hasn’t received anything, but the scene triggers (12 minutes after 1:00 PM). Behavior OK
- 1:15 PM: the MQTT device receives ‹&nbsp;0&nbsp;› again. Nothing happens (but this is where I suspect the trigger starts checking the 12-minute delay again). But for now, behavior OK
- 1:20 PM: the MQTT device receives ‹&nbsp;0&nbsp;› again. Nothing happens. Behavior OK
- 1:25 PM: the MQTT device receives ‹&nbsp;0&nbsp;› again. Nothing happens. Behavior OK
- 1:27 PM: the MQTT device hasn’t received anything, but the scene triggers (12 minutes after 1:15 PM). And this is the behavior that is not correct since the MQTT device hasn’t switched back to 1 since 1:12 PM!

Is that what you reproduced?

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [May 29, 2025, 12:38pm UTC](https://community.gladysassistant.com/t/defaut-dans-le-nouveau-declencheur-avec-delai/9225/9 "2025-05-29T12:38:26Z")

</div>

> [@StephaneB](#):
>
> Is that what you reproduced?

Yes, that’s it, and I get the expected behavior 🙂

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [May 29, 2025, 12:44pm UTC](https://community.gladysassistant.com/t/defaut-dans-le-nouveau-declencheur-avec-delai/9225/10 "2025-05-29T12:44:43Z")

</div>

I just ran a test even closer to your case, by sending multiple 0s (during the timeout, and after the timeout):

 ![Screenshot 2025-05-29 at 14.42.36](https://gladys-assistant-community.b-cdn.net/uploads/default/original/3X/3/5/351a1ef1b8d66ec5bbf99e0b7dc7b299bdfd82dd.png)

And I observed the expected behavior! Sorry 😅

If you want to investigate further, in the logs you should have 2 log entries:

```auto
2025-05-29T14:40:39+0200 \u003cinfo\u003e scene.triggers.js:61 (Object.device.new-state) Scheduling timer to check for device_feature "mqtt:connexion-internet-perdue" state in 60000ms

```

(Starting the timer)

And:

```auto
2025-05-29T14:41:39+0200 \u003cinfo\u003e scene.triggers.js:43 (Object.device.new-state) Scene trigger device.new-state: Timer for sensor mqtt:connexion-internet-perdue has finished.

```

(End of the timer)

In my tests, the timer only starts once

---

<div class="post-metadata">

**Author:** ![StephaneB](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/stephaneb/32/15443_2.png) [@StephaneB](https://community.gladysassistant.com/u/StephaneB)\
**Post date:** [May 29, 2025, 2:21pm UTC](https://community.gladysassistant.com/t/defaut-dans-le-nouveau-declencheur-avec-delai/9225/11 "2025-05-29T14:21:12Z")

</div>

Alright, I’ll take another look at it on Saturday or Sunday, I’ll keep you posted.

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [May 29, 2025, 2:38pm UTC](https://community.gladysassistant.com/t/defaut-dans-le-nouveau-declencheur-avec-delai/9225/12 "2025-05-29T14:38:33Z")

</div>

Keep me posted!

---

<div class="post-metadata">

**Author:** ![StephaneB](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/stephaneb/32/15443_2.png) [@StephaneB](https://community.gladysassistant.com/u/StephaneB)\
**Post date:** [June 1, 2025, 9:56pm UTC](https://community.gladysassistant.com/t/defaut-dans-le-nouveau-declencheur-avec-delai/9225/13 "2025-06-01T21:56:12Z")

</div>

Well, the trigger works perfectly. And it must be me who’s bugged 😜

Sorry for wasting your time, @pierre-gilles

I’ll take this opportunity to close the topic.

---

<div class="post-metadata">

**Author:** ![StephaneB](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/stephaneb/32/15443_2.png) [@StephaneB](https://community.gladysassistant.com/u/StephaneB)\
**Post date:** [June 1, 2025, 9:56pm UTC](https://community.gladysassistant.com/t/defaut-dans-le-nouveau-declencheur-avec-delai/9225/14 "2025-06-01T21:56:17Z")

</div>


