Node-Red Flow

Flow – Set Date and Time

Posted on Updated on

I needed for a user interface using dashboard to change the system date and time for only offline use.

Set time zone using raspi-config to UTC

and then:

[{"id":"36c3d555.2f131a","type":"ui_form","z":"95a3d4b7.c328c","name":"","label":"Time Setting","group":"d5789dec.c52058","order":0,"width":0,"height":0,"options":[{"label":"Fri Nov 4 17:50:00 UTC 2016","value":"Time","type":"text","required":true}],"formValue":{"Time":""},"payload":"","topic":"","x":116.5,"y":66,"wires":[["a31c7a2b.05a228"]]},{"id":"b1edd921.e154a","type":"exec","z":"95a3d4b7.c328c","command":"sudo date","addpay":true,"append":"","useSpawn":"","timer":"","name":"Set Time","x":431.5,"y":64.5,"wires":[["23954dbb.e1b912"],[],[]]},{"id":"d0531b60.f27f88","type":"ui_text","z":"95a3d4b7.c328c","group":"d5789dec.c52058","order":0,"width":"0","height":"0","name":"","label":"Actual System Date and Time","format":"{{msg.payload}}","layout":"row-spread","x":505.5,"y":157,"wires":[]},{"id":"9f79c87.21b00b8","type":"inject","z":"95a3d4b7.c328c","name":"","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":true,"x":122.5,"y":153,"wires":[["5f3c74a9.0f72bc"]]},{"id":"23954dbb.e1b912","type":"debug","z":"95a3d4b7.c328c","name":"","active":true,"console":"false","complete":"false","x":608.5,"y":64,"wires":[]},{"id":"5f3c74a9.0f72bc","type":"function","z":"95a3d4b7.c328c","name":"","func":"// Create a Date object from the payload\nvar date = new Date(msg.payload);\n// Change the payload to be a formatted Date string\nmsg.payload = date.toString();\n// Return the message so it can be sent on\nreturn msg;","outputs":1,"noerr":0,"x":278.5,"y":156,"wires":[["d0531b60.f27f88"]]},{"id":"e2689290.c72908","type":"function","z":"95a3d4b7.c328c","name":"","func":"msg.payload = \"-\" +'\"' + \"s \" + msg.payload + '\"';\nreturn msg;\n\n//sudo date -\"s Fri Nov 4 17:50:00 UTC 2016\"","outputs":1,"noerr":0,"x":274.5,"y":273,"wires":[["26012639.277dea"]]},{"id":"adb62291.b5d0c8","type":"inject","z":"95a3d4b7.c328c","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":126.5,"y":273,"wires":[["e2689290.c72908"]]},{"id":"26012639.277dea","type":"debug","z":"95a3d4b7.c328c","name":"","active":true,"console":"false","complete":"false","x":458.5,"y":274,"wires":[]},{"id":"a31c7a2b.05a228","type":"function","z":"95a3d4b7.c328c","name":"","func":"var strtime = msg.payload.Time;\nmsg.payload = \"-\" +'\"' + \"s \" + strtime + '\"';\nreturn msg;","outputs":1,"noerr":0,"x":276,"y":65,"wires":[["26012639.277dea","b1edd921.e154a"]]},{"id":"d5789dec.c52058","type":"ui_group","z":"","name":"Time Setting","tab":"862d2fe5.7ba4a","order":1,"disp":false,"width":"16"},{"id":"862d2fe5.7ba4a","type":"ui_tab","z":"","name":"Setting","icon":"dashboard","order":2}]
Advertisements

Flow – Send command

Posted on Updated on

A couple of commands example.

 [{"id":"9d317c9d.94ec4","type":"inject","z":"95dd8c1e.9f45b8","name":"shutdown!","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":254,"y":105,"wires":[["47b1920.62f3bf"]]},{"id":"47b1920.62f3bf","type":"exec","z":"95dd8c1e.9f45b8","command":"sudo poweroff #","append":"","useSpawn":"","name":"turn off Pi","x":428,"y":104,"wires":[[],[],[]]},{"id":"28150e2f.21a1ea","type":"inject","z":"95dd8c1e.9f45b8","name":"reboot!","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":255,"y":188,"wires":[["f211e72e.571f78"]]},{"id":"f211e72e.571f78","type":"exec","z":"95dd8c1e.9f45b8","command":"sudo reboot #","addpay":false,"append":"","useSpawn":"","timer":"","name":"Reboot Pi","x":430,"y":193,"wires":[[],[],[]]},{"id":"9fdf1eef.cd09f","type":"inject","z":"95dd8c1e.9f45b8","name":"video off","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":248,"y":277,"wires":[["d5a598dc.db0b9"]]},{"id":"d5a598dc.db0b9","type":"exec","z":"95dd8c1e.9f45b8","command":"vcgencmd display_power 0","addpay":false,"append":"","useSpawn":"","timer":"","name":"Video Off","x":431,"y":279,"wires":[[],[],[]]}]

screen-shot-2016-11-05-at-7-21-04-am

Flow – Dashboard Reset Chart

Posted on Updated on

If you like to reset the content of a graph in Node-Red dashboard, use this method.

[{"id":"69c51240.a88d64","type":"ui_chart","z":"95dd8c1e.9f45b8","name":"","group":"982d5ce1.fdf228","order":4,"width":"5","height":"2","label":"","chartType":"line","legend":"false","xformat":"%H:%M","interpolate":"linear","nodata":"","ymin":"-40","ymax":"80","removeOlder":1,"removeOlderUnit":"3600","x":521,"y":119,"wires":[[],[]]},{"id":"9475826e.ef16e","type":"json","z":"95dd8c1e.9f45b8","name":"","x":348.5,"y":121,"wires":[["69c51240.a88d64"]]},{"id":"72de27fd.a64e08","type":"inject","z":"95dd8c1e.9f45b8","name":"Reset","topic":"","payload":"[ { \"key\": \"Data\", \"values\": []}]","payloadType":"str","repeat":"","crontab":"","once":false,"x":185.5,"y":121,"wires":[["9475826e.ef16e"]]},{"id":"982d5ce1.fdf228","type":"ui_group","name":"Group 1","tab":"6db0468b.7fc248","order":1,"disp":true,"width":6},{"id":"6db0468b.7fc248","type":"ui_tab","z":"","name":"Test","icon":"dashboard","order":3}]

screen-shot-2016-11-04-at-11-34-54-pm