DIsplay UNIX time from a node in yyyy-MM-dd HH:mm format on a Dashboard

I am receiving a date from openeathermap in Unix format and I would like to display the date in a dashboard in the yyyy-MM-dd HH:mm format.

What I did:

Set up a timestamp inject node to trigger the read:

I use an edit change node to change the message for temperatures that work perfect for me:

I then tried to do the same with sunrise time:

I no receive the Unix time on my dashboard:
image
image

As a NON-DEVELOPER I tried my best to understand this:

and tried this:

and NO sunrise date / time is showing.

I need some help to fix this, Please

You can format the date with angularjs filters in the ui nodes just times by 1000. You don't need to move the values to payload.
e.g.
Value format field

{{msg.payload.sys.sunrise * 1000 | date : "yyyy-MM-dd HH:mm"}}
[{"id":"e9c46733dde4fe28","type":"inject","z":"452103ea51141731","name":"","props":[{"p":"payload.sys.sunrise","v":"1677143063","vt":"num"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":130,"y":4740,"wires":[["ab40d4ca63acfdd9","2b6ccc1aa23dd831"]]},{"id":"ab40d4ca63acfdd9","type":"debug","z":"452103ea51141731","name":"debug 234","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":510,"y":4720,"wires":[]},{"id":"2b6ccc1aa23dd831","type":"ui_text","z":"452103ea51141731","group":"2d4fe667.28f8ba","order":19,"width":0,"height":0,"name":"","label":"text","format":"{{msg.payload.sys.sunrise * 1000 | date : \"yyyy-MM-dd HH:mm\"}}","layout":"row-spread","className":"","x":290,"y":4760,"wires":[]},{"id":"2d4fe667.28f8ba","type":"ui_group","name":"demo","tab":"1caa8458.b17814","order":2,"disp":true,"width":"12","collapse":false},{"id":"1caa8458.b17814","type":"ui_tab","name":"Demo","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

Sorry @E1cid ,

It is not working for me:

image

Did I perhaps include / exclude brackets or spaces?

Have you moved the values in the change nodes? if so don't.

Also please supply your incoming JSON from openweather in a copyable form.

This is my node:-

[{"id":"406768ea.130408","type":"inject","z":"90ad4c26.ecec5","name":"","topic":"Midstream Weather","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":1820,"wires":[["3f4b7628.05aaea"]]},{"id":"3f4b7628.05aaea","type":"http request","z":"90ad4c26.ecec5","name":"Midstream","method":"GET","ret":"obj","paytoqs":false,"url":"https://api.openweathermap.org/data/2.5/weather?lat=-25.9964&lon=28.2268&appid=8180814af046016d40fbc9ddce00b19d&units=metric","tls":"","persist":false,"proxy":"","authType":"","x":430,"y":1820,"wires":[["9a394ee.15c7db","769a34c4.92088c","9ff88257.65b56","8129ddb8.e16c7","65366610.0e1b98","a974154f.32c9b8"]]},{"id":"9a394ee.15c7db","type":"debug","z":"90ad4c26.ecec5","name":"","active":false,"tosidebar":true,"console":true,"tostatus":false,"complete":"true","targetType":"full","x":850,"y":1820,"wires":[]},{"id":"6b2c6abc.1df994","type":"comment","z":"90ad4c26.ecec5","name":"Weather call","info":"","x":1050,"y":1860,"wires":[]},{"id":"65366610.0e1b98","type":"change","z":"90ad4c26.ecec5","name":"Sunrise","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.sys.sunrise","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":2100,"wires":[["9799b2b8.1fb64","ebcb5af7.399168","f9a48354.b8ef2"]]},{"id":"a974154f.32c9b8","type":"change","z":"90ad4c26.ecec5","name":"Sunset","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.sys.sunset","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":2201,"wires":[["8307dd7c.51c3c","b836b9a4.59ea28"]]},{"id":"9799b2b8.1fb64","type":"debug","z":"90ad4c26.ecec5","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1570,"y":2100,"wires":[]},{"id":"8307dd7c.51c3c","type":"debug","z":"90ad4c26.ecec5","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1570,"y":2201,"wires":[]},{"id":"769a34c4.92088c","type":"change","z":"90ad4c26.ecec5","name":"Current Temp","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.main.temp","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":1940,"wires":[["c2e03a6f.3871c8","90fbddad.3239"]]},{"id":"c2e03a6f.3871c8","type":"debug","z":"90ad4c26.ecec5","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1570,"y":1940,"wires":[]},{"id":"9ff88257.65b56","type":"change","z":"90ad4c26.ecec5","name":"Min Temp","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.main.temp_min","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":1980,"wires":[["8b109f2b.f88e7","11ad7a9a.a736c5"]]},{"id":"8129ddb8.e16c7","type":"change","z":"90ad4c26.ecec5","name":"Max Temp","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.main.temp_max","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":650,"y":2020,"wires":[["cd8afb8f.99ed48","81f4c601.c24e68"]]},{"id":"8b109f2b.f88e7","type":"debug","z":"90ad4c26.ecec5","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1570,"y":1980,"wires":[]},{"id":"cd8afb8f.99ed48","type":"debug","z":"90ad4c26.ecec5","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1570,"y":2020,"wires":[]},{"id":"90fbddad.3239","type":"ui_text","z":"90ad4c26.ecec5","group":"b89e7b15.bc4868","order":0,"width":0,"height":0,"name":"","label":"Current Temp","format":"{{msg.payload}}","layout":"row-spread","className":"","x":900,"y":1920,"wires":[]},{"id":"11ad7a9a.a736c5","type":"ui_text","z":"90ad4c26.ecec5","group":"b89e7b15.bc4868","order":1,"width":0,"height":0,"name":"","label":"Min Temp","format":"{{msg.payload}}","layout":"row-spread","className":"","x":880,"y":1960,"wires":[]},{"id":"81f4c601.c24e68","type":"ui_text","z":"90ad4c26.ecec5","group":"b89e7b15.bc4868","order":2,"width":0,"height":0,"name":"","label":"Max Temp","format":"{{msg.payload}}","layout":"row-spread","className":"","x":890,"y":2000,"wires":[]},{"id":"ebcb5af7.399168","type":"ui_text","z":"90ad4c26.ecec5","group":"b89e7b15.bc4868","order":3,"width":0,"height":0,"name":"","label":"text","format":"{{msg.payload}}","layout":"row-spread","className":"","x":870,"y":2080,"wires":[]},{"id":"b836b9a4.59ea28","type":"ui_text","z":"90ad4c26.ecec5","group":"b89e7b15.bc4868","order":4,"width":0,"height":0,"name":"","label":"text","format":"{{msg.payload}}","layout":"row-spread","className":"","x":870,"y":2181,"wires":[]},{"id":"f9a48354.b8ef2","type":"ui_text","z":"90ad4c26.ecec5","group":"b89e7b15.bc4868","order":5,"width":0,"height":0,"name":"Sunrise 2","label":"Sunrise 2","format":"{{msg.payload.sys.sunrise * 1000 | date : \"yyyy-MM-dd HH:mm\"}}","layout":"row-spread","className":"","x":880,"y":2120,"wires":[]},{"id":"b89e7b15.bc4868","type":"ui_group","z":"","name":"Test2","tab":"f7d5b107.3e578","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"f7d5b107.3e578","type":"ui_tab","z":"","name":"Test2","icon":"dashboard","disabled":false,"hidden":false}]

I never asked for your flow, i asked for the output JSON of the openweather node.

As said before do not move/set msg.payload.sys.sunrise to msg.payload, as it overwrites payload.

To be clear, remove the change node.

Ps. you have added you api key and it is clear to view from the internet, either change your api key or edit your post.

[edit]
Working here for me i have removed api key in this example flow.

[{"id":"406768ea.130408","type":"inject","z":"452103ea51141731","name":"","props":[{"p":"payload","v":"","vt":"date"},{"p":"topic","v":"Midstream Weather","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Midstream Weather","payload":"","payloadType":"date","x":160,"y":4600,"wires":[["d19524e9774de766"]]},{"id":"d19524e9774de766","type":"http request","z":"452103ea51141731","name":"Midstream","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://api.openweathermap.org/data/2.5/weather?lat=-25.9964&lon=28.2268&appid=[add_api_key]&units=metric","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"credentials":{},"x":250,"y":4660,"wires":[["2b6ccc1aa23dd831"]]},{"id":"2b6ccc1aa23dd831","type":"ui_text","z":"452103ea51141731","group":"2d4fe667.28f8ba","order":19,"width":0,"height":0,"name":"","label":"text","format":"{{msg.payload.sys.sunrise * 1000 | date : \"yyyy-MM-dd HH:mm\"}}","layout":"row-spread","className":"","x":410,"y":4660,"wires":[]},{"id":"2d4fe667.28f8ba","type":"ui_group","name":"demo","tab":"1caa8458.b17814","order":2,"disp":true,"width":"12","collapse":false},{"id":"1caa8458.b17814","type":"ui_tab","name":"Demo","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

In fact you should present the flow with the least nodes that shows your issue, i would of presented just two or three nodes like this

[{"id":"2b6ccc1aa23dd831","type":"ui_text","z":"452103ea51141731","group":"2d4fe667.28f8ba","order":19,"width":0,"height":0,"name":"","label":"text","format":"{{msg.payload.sys.sunrise * 1000 | date : \"yyyy-MM-dd HH:mm\"}}","layout":"row-spread","className":"","x":410,"y":4660,"wires":[]},{"id":"406768ea.130408","type":"inject","z":"452103ea51141731","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Midstream Weather","payload":"{\"coord\":{\"lon\":28.2268,\"lat\":-25.9964},\"weather\":[{\"id\":800,\"main\":\"Clear\",\"description\":\"clear sky\",\"icon\":\"01d\"}],\"base\":\"stations\",\"main\":{\"temp\":27.26,\"feels_like\":27.95,\"temp_min\":24.62,\"temp_max\":30.16,\"pressure\":1014,\"humidity\":54,\"sea_level\":1014,\"grnd_level\":851},\"visibility\":10000,\"wind\":{\"speed\":3.04,\"deg\":96,\"gust\":3.69},\"clouds\":{\"all\":0},\"dt\":1677153144,\"sys\":{\"type\":2,\"id\":2037341,\"country\":\"ZA\",\"sunrise\":1677124635,\"sunset\":1677170648},\"timezone\":7200,\"id\":949880,\"name\":\"Tembisa\",\"cod\":200}","payloadType":"json","x":230,"y":4660,"wires":[["2b6ccc1aa23dd831"]]},{"id":"2d4fe667.28f8ba","type":"ui_group","name":"demo","tab":"1caa8458.b17814","order":2,"disp":true,"width":"12","collapse":false},{"id":"1caa8458.b17814","type":"ui_tab","name":"Demo","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

All info is there and there is no confusion as to what nodes have the issue.

I have shared a temporary API so I will just delete it now

I think I am still on a very old ver :smiling_face:

Thank you @E1cid for taking the time to guide me in doing my flows in the correct way.
I appreciate it very much!

I have now updated my Node-RED to the latest and suddenly things are much easier to do.

My dashboard is coming on nicely now!

I will be adding some extra nodes to the dashboard as the further it grows the more useful things I identify I should add.

Thanks for helping me to achieve my goal.

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