# Check availability of all sensors

**URL:** <https://discourse.nodered.org/t/check-availability-of-all-sensors/90939>\
**Category:** General\
**Created:** [13 September 2024 10:16 UTC](https://discourse.nodered.org/t/check-availability-of-all-sensors/90939 "2024-09-13T10:16:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kralle](https://avatars.discourse-cdn.com/v4/letter/k/7cd45c/32.png) [@Kralle](https://discourse.nodered.org/u/Kralle)\
**Post date:** [13 September 2024 10:16 UTC](https://discourse.nodered.org/t/check-availability-of-all-sensors/90939/1 "2024-09-13T10:16:32Z")

</div>

We monitor temperatures in cold stores using Node Red and Dragino LSN50 sensors. The sensors transmit every 20 minutes. I'll add a screenshot. I would now like to monitor all sensors to see whether a payload is sent at all. If not, an email should be sent after a certain time. How do you realize that??  
Thank you.  
 ![Screenshot 2024-09-13 120936](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/c/ec88a7df27f9a1594fb5bd898b1eb7b00a6c7e54.png)  
 ![Screenshot 2024-09-13 121032](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/0/608b85be11aa4dd0779a3ba77abb58cb1648fcbf.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [13 September 2024 10:32 UTC](https://discourse.nodered.org/t/check-availability-of-all-sensors/90939/2 "2024-09-13T10:32:14Z")

</div>

You can use a Trigger node for this. Configure it to Send Nothing, wait 21 minutes, then Send the email message. Also set Extend Delay if No Message Arrives. The result is that every time a new message arrives it will restart the timer, so the email message will never be sent. If 21 minutes elapses without an input then it will send the email message.  
You may want to configure an Inject node to send the trigger a message on startup to prime the timer, so that you will get your email if node-red is restarted and no data is received from the sensor.

---

<div class="post-metadata">

**Author:** ![Kralle](https://avatars.discourse-cdn.com/v4/letter/k/7cd45c/32.png) [@Kralle](https://discourse.nodered.org/u/Kralle)\
**Post date:** [13 September 2024 11:11 UTC](https://discourse.nodered.org/t/check-availability-of-all-sensors/90939/3 "2024-09-13T11:11:40Z")

</div>

Do you have an example?? Trigger is known. After 21 minutes, what should be in Sent then and after the trigger node just an email node??

 ![Screenshot 2024-09-13 131116](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/6/163e533f27c268d7ea6476c0d1ceeb4a314bcaab.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [13 September 2024 12:32 UTC](https://discourse.nodered.org/t/check-availability-of-all-sensors/90939/5 "2024-09-13T12:32:34Z")

</div>

> [@Kralle](#):
>
> what should be in Sent

That is up to you. If you want to send an email then put there whatever you want to send to the email node. Get that going first, using an Inject node to send it a message. Then you can easily test it just by clicking the inject. Once you have it working then you can wire it up to the Trigger.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [13 September 2024 12:45 UTC](https://discourse.nodered.org/t/check-availability-of-all-sensors/90939/6 "2024-09-13T12:45:43Z")

</div>

> [@Kralle](#):
>
> After 21 minutes, what should be in Sent then and after the trigger node just an email node??

As you are getting sensor values from MQTT, I assume that each sensor's message has a unique msg.topic.

Note that the trigger node should be set to handle each msg.topic separately.

Something like this might work. I set my trigger to 21 seconds for easy testing.

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

```auto
[{"id":"22beb24c8059f0a6","type":"trigger","z":"db04fd79f3a93d19","name":"","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"21","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"topic","topic":"topic","outputs":1,"x":410,"y":1180,"wires":[["5af2e306db133633"]]},{"id":"5af2e306db133633","type":"change","z":"db04fd79f3a93d19","name":"Format email","rules":[{"t":"set","p":"topic","pt":"msg","to":"topic & \" may be offline\"","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"\"Last seen \" & lastseen","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":1180,"wires":[["34b5504756faa229"]]},{"id":"7d66973cdca0b813","type":"change","z":"db04fd79f3a93d19","name":"","rules":[{"t":"set","p":"lastseen","pt":"msg","to":"$now()","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":230,"y":1180,"wires":[["22beb24c8059f0a6"]]},{"id":"34b5504756faa229","type":"link out","z":"db04fd79f3a93d19","name":"To email","mode":"link","links":[],"x":720,"y":1180,"wires":[],"l":true}]

```

I get an email with a title like `sensors/temperature/door may be offline` and content `Last seen 2024-09-13T12:36:11.421Z`

---

<div class="post-metadata">

**Author:** ![Shafaqat](https://avatars.discourse-cdn.com/v4/letter/s/8491ac/32.png) [@Shafaqat](https://discourse.nodered.org/u/Shafaqat)\
**Post date:** [14 September 2024 06:18 UTC](https://discourse.nodered.org/t/check-availability-of-all-sensors/90939/7 "2024-09-14T06:18:37Z")

</div>

Great Thaks for a lot of

---

<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:** [13 December 2024 06:19 UTC](https://discourse.nodered.org/t/check-availability-of-all-sensors/90939/8 "2024-12-13T06:19:02Z")

</div>

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