# How to detect unused flow (missing mqtt input)

**URL:** <https://discourse.nodered.org/t/how-to-detect-unused-flow-missing-mqtt-input/72710>\
**Category:** General\
**Tags:** mqtt\
**Created:** [26 December 2022 08:44 UTC](https://discourse.nodered.org/t/how-to-detect-unused-flow-missing-mqtt-input/72710 "2022-12-26T08:44:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![AndKe](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andke/32/73023_2.png) [@AndKe](https://discourse.nodered.org/u/AndKe)\
**Post date:** [26 December 2022 08:44 UTC](https://discourse.nodered.org/t/how-to-detect-unused-flow-missing-mqtt-input/72710/1 "2022-12-26T08:44:54Z")

</div>

Some MQTT devices battery die, then there is no mqtt-in input.  
What is the proper way to cause some action - when a input/mqtt-in has not seen data(been used) for x hours?

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [26 December 2022 08:51 UTC](https://discourse.nodered.org/t/how-to-detect-unused-flow-missing-mqtt-input/72710/2 "2022-12-26T08:51:21Z")

</div>

You could use the Trigger node for such monitoring. As long as the message arrives at a regular interval you extend the delay. Once it fires, means when no message has arrived within the defined interval, you get an output that you could use to inform you about this. In my case I use many Trigger nodes in this way and I send alerts to Telegram when some component, service or sensor may fail

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [26 December 2022 08:57 UTC](https://discourse.nodered.org/t/how-to-detect-unused-flow-missing-mqtt-input/72710/3 "2022-12-26T08:57:53Z")

</div>

You should be able to set a last will time, then when broker does not hear from the device in x time, it can send a last will message to node read, which should subscribe to the last will topic.

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [26 December 2022 16:59 UTC](https://discourse.nodered.org/t/how-to-detect-unused-flow-missing-mqtt-input/72710/4 "2022-12-26T16:59:58Z")

</div>

Sure you can use "last will" but using the Trigger gives a bonus, always showing the actual status of all your (monitored) sensors etc in the flow

But is a matter of personal choice of course

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/e/2e629048eb0d284b9f71ed94430fc821f1aa6489.png)

---

<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:** [24 February 2023 17:00 UTC](https://discourse.nodered.org/t/how-to-detect-unused-flow-missing-mqtt-input/72710/5 "2023-02-24T17:00:56Z")

</div>

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