# How do I get the time from the last point in a Node-red dashboard chart

**URL:** <https://discourse.nodered.org/t/how-do-i-get-the-time-from-the-last-point-in-a-node-red-dashboard-chart/77318>\
**Category:** General\
**Created:** [6 April 2023 15:51 UTC](https://discourse.nodered.org/t/how-do-i-get-the-time-from-the-last-point-in-a-node-red-dashboard-chart/77318 "2023-04-06T15:51:34Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![alveron](https://avatars.discourse-cdn.com/v4/letter/a/b77776/32.png) [@alveron](https://discourse.nodered.org/u/alveron)\
**Post date:** [6 April 2023 15:51 UTC](https://discourse.nodered.org/t/how-do-i-get-the-time-from-the-last-point-in-a-node-red-dashboard-chart/77318/1 "2023-04-06T15:51:34Z")

</div>

I have a chart being populated from a datalogger. Sometimes the connection goes bad, so I would like to publish the time of the last plotted point so I can monitor it and potentially act if I have not received data for a while.  
Thanks in advance.

---

<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:** [6 April 2023 16:23 UTC](https://discourse.nodered.org/t/how-do-i-get-the-time-from-the-last-point-in-a-node-red-dashboard-chart/77318/2 "2023-04-06T16:23:59Z")

</div>

Add a debug node to the chart output, the data is all there.

---

<div class="post-metadata">

**Author:** ![alveron](https://avatars.discourse-cdn.com/v4/letter/a/b77776/32.png) [@alveron](https://discourse.nodered.org/u/alveron)\
**Post date:** [6 April 2023 20:26 UTC](https://discourse.nodered.org/t/how-do-i-get-the-time-from-the-last-point-in-a-node-red-dashboard-chart/77318/3 "2023-04-06T20:26:19Z")

</div>

Thanks, yes I can see all there, being new to node-red, some advice on how to pull out what I need.  
Is this something I can use a change node to access the data, or are we looking at a function node as the only way to get what I need??

---

<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:** [6 April 2023 20:48 UTC](https://discourse.nodered.org/t/how-do-i-get-the-time-from-the-last-point-in-a-node-red-dashboard-chart/77318/4 "2023-04-06T20:48:47Z")

</div>

> [@alveron](#):
>
> I would like to publish the time of the last plotted point so I can monitor it and potentially act if I have not received data for a while.

There are probably better ways of doing that. Can you explain in a bit more detail what problem you are trying to catch? What connection is it that goes bad? Where do you want to publish the time to and where do you want to interpret that time?

---

<div class="post-metadata">

**Author:** ![alveron](https://avatars.discourse-cdn.com/v4/letter/a/b77776/32.png) [@alveron](https://discourse.nodered.org/u/alveron)\
**Post date:** [6 April 2023 20:59 UTC](https://discourse.nodered.org/t/how-do-i-get-the-time-from-the-last-point-in-a-node-red-dashboard-chart/77318/5 "2023-04-06T20:59:05Z")

</div>

Thanks, Sure can do that...  
The logger I have connects through Wifi (mqtt) and is pushing the connection envelope a bit due to distance.  
Mostly it works fine, but I would like to know if it's having a bad day. My thought was if I could capture the time assigned to the last captured point and then publish it to the dashboard I could easily see if I am losing data, eventually I would like to set up a notification, so I would be informed when this happens. Right now, the chart is setup to gather 2 days of data which comes at 30 sec intervals (so there is a lot of points)

---

<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:** [6 April 2023 21:08 UTC](https://discourse.nodered.org/t/how-do-i-get-the-time-from-the-last-point-in-a-node-red-dashboard-chart/77318/6 "2023-04-06T21:08:19Z")

</div>

If the logger provides MQTT Last Will and Testament then you should be able to use that to detect if it loses connection. See the link below if you don't know about LWT, basically it allows the broker to tell you if the client disconnects.

Otherwise, if you connect a Trigger node to the incoming messages node (as well as going to the chart), and configure the trigger like this

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/a/ba7cbcb29f577d3a9555a104465df64c7757f725.png)

Then all the time data keeps coming in it does not send anything. If no data arrives for 10 seconds (or whatever you have configured) then it sends a message, which you can use to do whatever you like.

To learn more about MQTT then see this tutorial [MQTT Essentials - All Core Concepts explained](https://www.hivemq.com/mqtt-essentials/)

---

<div class="post-metadata">

**Author:** ![alveron](https://avatars.discourse-cdn.com/v4/letter/a/b77776/32.png) [@alveron](https://discourse.nodered.org/u/alveron)\
**Post date:** [7 April 2023 12:36 UTC](https://discourse.nodered.org/t/how-do-i-get-the-time-from-the-last-point-in-a-node-red-dashboard-chart/77318/7 "2023-04-07T12:36:58Z")

</div>

Thank you, much easier than my solution, and so many more possibilities.  
I used a Change node to reset the warning message once the data stream continued.  
This can now be extended to make a chart showing when data dropouts occurred.  
Excellent !

---

<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:** [7 April 2023 13:09 UTC](https://discourse.nodered.org/t/how-do-i-get-the-time-from-the-last-point-in-a-node-red-dashboard-chart/77318/8 "2023-04-07T13:09:43Z")

</div>

Which solution did you use? LWT or Trigger node?

---

<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:** [6 June 2023 13:10 UTC](https://discourse.nodered.org/t/how-do-i-get-the-time-from-the-last-point-in-a-node-red-dashboard-chart/77318/9 "2023-06-06T13:10:40Z")

</div>

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