Dashboard UI - Set Local Timezone

With this flow it is possible to change the local timezone using node-red-dashboard ui

image

Buy Me A Coffee

[{"id":"53b8a60c.b0cba8","type":"tab","label":"Timezone","disabled":false,"info":""},{"id":"12e0203f.d58be","type":"inject","z":"53b8a60c.b0cba8","name":"init","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":198,"y":122,"wires":[["4ad793f9.1fbdbc"]]},{"id":"4ad793f9.1fbdbc","type":"function","z":"53b8a60c.b0cba8","name":"Read locales","func":"var TZ = [\"Africa\",\"Asia\",\"Canada\",\"Indian\",\"US\",\"America\",\"Atlantic\",\"Chile\",\"Mexico\",\"Antarctica\",\"Australia\",\"Pacific\",\"Arctic\",\"Brazil\",\"Europe\"]\n\nfor(let i=0;i<TZ.length;i++) {\n    node.send({topic: TZ[i], payload: '/usr/share/zoneinfo/' + TZ[i] + '/', init: i === TZ.length-1})\n}\n","outputs":1,"noerr":0,"x":417,"y":121,"wires":[["c6fd0daf.8c482"]]},{"id":"c6fd0daf.8c482","type":"exec","z":"53b8a60c.b0cba8","command":"ls ","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":589,"y":121,"wires":[["ebd4dca4.ab828","3e2e7b0e.683ce4"],[],[]]},{"id":"ebd4dca4.ab828","type":"function","z":"53b8a60c.b0cba8","name":"set flow vars","func":"var areas = msg.payload.split('\\n').filter(a => !!a)\n\nflow.set(msg.topic, areas)","outputs":0,"noerr":0,"x":760,"y":107,"wires":[]},{"id":"3e2e7b0e.683ce4","type":"switch","z":"53b8a60c.b0cba8","name":"if init","property":"init","propertyType":"msg","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":757,"y":167,"wires":[["467bb794.f76f88"]]},{"id":"375407c3.992bd8","type":"ui_dropdown","z":"53b8a60c.b0cba8","name":"","label":"Area","tooltip":"","place":"Select area","group":"a1d8ed34.6a447","order":2,"width":0,"height":0,"passthru":true,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"","x":1084,"y":166,"wires":[["f1ff3b98.994be8"]]},{"id":"467bb794.f76f88","type":"function","z":"53b8a60c.b0cba8","name":"Set options","func":"var msg = {\n    options: flow.keys()\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":918,"y":166,"wires":[["375407c3.992bd8"]]},{"id":"f4e22fd6.746d3","type":"ui_dropdown","z":"53b8a60c.b0cba8","name":"","label":"City","tooltip":"","place":"Select city","group":"a1d8ed34.6a447","order":3,"width":0,"height":0,"passthru":true,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"","x":1167,"y":250,"wires":[["7866d4d5.6cf34c"]]},{"id":"f1ff3b98.994be8","type":"function","z":"53b8a60c.b0cba8","name":"Set cities","func":"global.set(\"area\", msg.payload)\nglobal.set(\"city\", \"\")\n\nmsg = {options: flow.get(msg.payload)}\nreturn msg;","outputs":1,"noerr":0,"x":1237,"y":166,"wires":[["f4e22fd6.746d3"]]},{"id":"7866d4d5.6cf34c","type":"function","z":"53b8a60c.b0cba8","name":"Set cities","func":"global.set(\"city\", msg.payload)","outputs":0,"noerr":0,"x":1312,"y":250,"wires":[]},{"id":"65e64af0.16f134","type":"inject","z":"53b8a60c.b0cba8","name":"","topic":"","payload":"area","payloadType":"global","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":933,"y":203,"wires":[["375407c3.992bd8"]]},{"id":"8c4767e4.d55908","type":"inject","z":"53b8a60c.b0cba8","name":"","topic":"","payload":"city","payloadType":"global","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":999,"y":262,"wires":[["f4e22fd6.746d3"]]},{"id":"66cfa78b.b5b6d8","type":"inject","z":"53b8a60c.b0cba8","name":"","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":true,"onceDelay":0.1,"x":219,"y":207,"wires":[["5ad77235.78a39c"]]},{"id":"5ad77235.78a39c","type":"exec","z":"53b8a60c.b0cba8","command":"date","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":373,"y":207,"wires":[["98d0bf7f.5371d"],[],[]]},{"id":"98d0bf7f.5371d","type":"ui_text","z":"53b8a60c.b0cba8","group":"a1d8ed34.6a447","order":1,"width":0,"height":0,"name":"","label":"Date","format":"{{msg.payload}}","layout":"row-spread","x":560,"y":194,"wires":[]},{"id":"4fbda27f.7d015c","type":"ui_button","z":"53b8a60c.b0cba8","name":"","group":"a1d8ed34.6a447","order":8,"width":0,"height":0,"passthru":false,"label":"UPDATE","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":175,"y":319,"wires":[["27059364.3b4a8c"]]},{"id":"27059364.3b4a8c","type":"function","z":"53b8a60c.b0cba8","name":"update timezone","func":"var command = '/usr/share/zoneinfo/'+global.get(\"area\")+'/'+global.get(\"city\")+' /etc/localtime'\nnode.send({payload: command})\n","outputs":1,"noerr":0,"x":357,"y":319,"wires":[["d759e33f.cecaa"]]},{"id":"d759e33f.cecaa","type":"exec","z":"53b8a60c.b0cba8","command":"sudo ln -sf","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":552,"y":319,"wires":[["5aea3ae6.980494"],["cd3f0ef2.cf60c"],[]]},{"id":"a0414d37.8132c","type":"ui_toast","z":"53b8a60c.b0cba8","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"","topic":"","name":"success","x":860,"y":305,"wires":[]},{"id":"ff28f510.a53508","type":"ui_toast","z":"53b8a60c.b0cba8","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"","topic":"","name":"error","x":851,"y":346,"wires":[]},{"id":"5aea3ae6.980494","type":"change","z":"53b8a60c.b0cba8","name":"success","rules":[{"t":"set","p":"payload","pt":"msg","to":"Timezone updated successfully","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":711,"y":305,"wires":[["a0414d37.8132c"]]},{"id":"cd3f0ef2.cf60c","type":"change","z":"53b8a60c.b0cba8","name":"error","rules":[{"t":"set","p":"payload","pt":"msg","to":"Error while updating timezone","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":719,"y":346,"wires":[["ff28f510.a53508"]]},{"id":"a1d8ed34.6a447","type":"ui_group","z":"","name":"Time","tab":"4d8d2f83.26819","disp":true,"width":"6","collapse":false},{"id":"4d8d2f83.26819","type":"ui_tab","z":"","name":"Settings","icon":"settings"}]

Flow Info

Created 2 years, 2 months ago
Updated 1 year, 3 months ago
Rating: 3.5 2

Owner

Node Types

Core
  • change (x2)
  • exec (x3)
  • function (x6)
  • inject (x4)
  • switch (x1)
  • tab (x1)
Other
  • ui_button (x1)
  • ui_dropdown (x2)
  • ui_group (x1)
  • ui_tab (x1)
  • ui_text (x1)
  • ui_toast (x2)

Tags

  • node-red-dashboard
  • dashboard
  • timezone
  • robertsLando
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option