Display time stamp from chart as text

Hello,
I am new to node-red and exploring items with small projects.
I am getting information from MQTT client and displaying that data as a chart. The chart is displaying x as time and y as humidity. I am also displaying the Humidity as a text for easy view. I want to do the same thing with timestamp.
image

The agenda behind is to see when my last reading was received. right now i have to go to the chart with my mouse cursor and see what time the last reading was received.

You can format a time and save it to a msg property, you can display it in the label with mustache {{msg.propertyname}}
e.g.

[{"id":"3672ee81.81efc2","type":"inject","z":"c74669a0.6a34f8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"$floor($random()*5)+18","payloadType":"jsonata","x":140,"y":3660,"wires":[["597f573b.2c86e8"]]},{"id":"597f573b.2c86e8","type":"change","z":"c74669a0.6a34f8","name":"","rules":[{"t":"set","p":"lastReadingTime","pt":"msg","to":"$moment().tz(\"Europe/London\").format(\"HH:mm:ss\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":3660,"wires":[["6bab8166.1ff9c"]]},{"id":"6bab8166.1ff9c","type":"ui_chart","z":"c74669a0.6a34f8","name":"","group":"8b5cde76.edd58","order":6,"width":0,"height":0,"label":"chart {{msg.lastReadingTime}}","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"x":560,"y":3660,"wires":[[]]},{"id":"8b5cde76.edd58","type":"ui_group","name":"","tab":"8f03e639.85956","order":1,"disp":true,"width":"12","collapse":false},{"id":"8f03e639.85956","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

[edit] you can also display it in a ui-text node. on any tab.

[{"id":"add35aef.da65e","type":"change","z":"c74669a0.6a34f8","name":"","rules":[{"t":"set","p":"lastReadingTime","pt":"msg","to":"$moment().tz(\"Europe/London\").format(\"HH:mm:ss\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":390,"y":3620,"wires":[["421905f3.bc678c","8f74ed03.0df328"]]},{"id":"ee0ce326.77c9b","type":"inject","z":"c74669a0.6a34f8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"$floor($random()*5)+18","payloadType":"jsonata","x":190,"y":3620,"wires":[["add35aef.da65e"]]},{"id":"421905f3.bc678c","type":"ui_chart","z":"c74669a0.6a34f8","name":"","group":"8b5cde76.edd58","order":5,"width":0,"height":0,"label":"chart     ( Last reading {{msg.lastReadingTime}} )","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"x":610,"y":3620,"wires":[[]]},{"id":"8f74ed03.0df328","type":"ui_text","z":"c74669a0.6a34f8","group":"8b5cde76.edd58","order":7,"width":"5","height":"1","name":"","label":"Last Reading","format":"{{msg.lastReadingTime}}","layout":"row-spread","x":650,"y":3660,"wires":[]},{"id":"8b5cde76.edd58","type":"ui_group","name":"","tab":"8f03e639.85956","order":1,"disp":true,"width":"12","collapse":false},{"id":"8f03e639.85956","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]
1 Like

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