# Trigger output if value unchanged for X amount of time

**URL:** <https://discourse.nodered.org/t/trigger-output-if-value-unchanged-for-x-amount-of-time/30347>\
**Category:** General\
**Created:** [19 July 2020 17:18 UTC](https://discourse.nodered.org/t/trigger-output-if-value-unchanged-for-x-amount-of-time/30347 "2020-07-19T17:18:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mobile\_NR\_Env](https://avatars.discourse-cdn.com/v4/letter/m/8dc957/32.png) [@Mobile\_NR\_Env](https://discourse.nodered.org/u/Mobile_NR_Env)\
**Post date:** [19 July 2020 17:18 UTC](https://discourse.nodered.org/t/trigger-output-if-value-unchanged-for-x-amount-of-time/30347/1 "2020-07-19T17:18:01Z")

</div>

Hello!

I have a numerical sensor value Node-Red is reading from an MQTT topic.

Unfortunately the script writing the MQTT topic freezes at times. This flow needs to be stopped if that happens!

I'd like to be able to trigger an alternative flow output if the Node-Red flow sees any numerical value hang for longer than say 10 minutes....

Any pointers?

Cheers folks

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [19 July 2020 17:40 UTC](https://discourse.nodered.org/t/trigger-output-if-value-unchanged-for-x-amount-of-time/30347/2 "2020-07-19T17:40:32Z")

</div>

The trigger node is the one to try out for this sort of thing

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [20 July 2020 04:01 UTC](https://discourse.nodered.org/t/trigger-output-if-value-unchanged-for-x-amount-of-time/30347/3 "2020-07-20T04:01:18Z")

</div>

Yep maybe a RBE node before a trigger node - so values will go through to the trigger node (assuming they change) and then have a timeout on the trigger of say 10 minutes so if no new readings come through in that time the next action happens

Obviously if the script is running and sending the same value over and over then this will not work

(although you could look for a different property in the MQTT stream like time or some such i.e. something that you set in the script that will change each time)

Craig

---

<div class="post-metadata">

**Author:** ![Mobile\_NR\_Env](https://avatars.discourse-cdn.com/v4/letter/m/8dc957/32.png) [@Mobile\_NR\_Env](https://discourse.nodered.org/u/Mobile_NR_Env)\
**Post date:** [20 July 2020 09:10 UTC](https://discourse.nodered.org/t/trigger-output-if-value-unchanged-for-x-amount-of-time/30347/4 "2020-07-20T09:10:26Z")

</div>

It's definitely a starting point, I will take a look at that this eve.  
Thanks for taking the time to reply chaps!

---

<div class="post-metadata">

**Author:** ![Mobile\_NR\_Env](https://avatars.discourse-cdn.com/v4/letter/m/8dc957/32.png) [@Mobile\_NR\_Env](https://discourse.nodered.org/u/Mobile_NR_Env)\
**Post date:** [22 July 2020 09:38 UTC](https://discourse.nodered.org/t/trigger-output-if-value-unchanged-for-x-amount-of-time/30347/5 "2020-07-22T09:38:16Z")

</div>

Thanks!  
Here's a sample flow for anyone looking for a similar action.

```auto
[{"id":"300bbb3b.7456fc","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"d2476c1.5c1691","type":"rbe","z":"300bbb3b.7456fc","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":290,"y":220,"wires":[["3d3cd101.6761f6","182c7bc.dab3804"]]},{"id":"3d3cd101.6761f6","type":"trigger","z":"300bbb3b.7456fc","op1":"","op2":"HUNG","op1type":"pay","op2type":"str","duration":"30","extend":true,"units":"s","reset":"","bytopic":"all","name":"","x":470,"y":140,"wires":[["1867f9f9.ae21d6"]]},{"id":"1867f9f9.ae21d6","type":"switch","z":"300bbb3b.7456fc","name":"HUNG","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"HUNG","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":610,"y":140,"wires":[["615719ef.3a6ba8"]]},{"id":"2ddd6e48.a9e382","type":"inject","z":"300bbb3b.7456fc","name":"","topic":"","payload":"1","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":160,"wires":[["d2476c1.5c1691"]]},{"id":"f74ac156.c87748","type":"inject","z":"300bbb3b.7456fc","name":"","topic":"","payload":"2","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":108.75,"y":218.75,"wires":[["d2476c1.5c1691"]]},{"id":"c7acbbdd.bc6d4","type":"inject","z":"300bbb3b.7456fc","name":"","topic":"","payload":"3","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":280,"wires":[["d2476c1.5c1691"]]},{"id":"182c7bc.dab3804","type":"debug","z":"300bbb3b.7456fc","name":"Flow into usual working process","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":530,"y":220,"wires":[]},{"id":"615719ef.3a6ba8","type":"debug","z":"300bbb3b.7456fc","name":"\"Hung\" Action flow trigger","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":820,"y":140,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [5 August 2020 09:38 UTC](https://discourse.nodered.org/t/trigger-output-if-value-unchanged-for-x-amount-of-time/30347/6 "2020-08-05T09:38:19Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
