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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s