Clock & Calendar
Node-RED

Clock & Calendar

A Node-Red flow that shows a clock, day of the month and day of the week indicator. Just change the mqtt prefix.
A flow by HKDRJ

Download flow

Flow Details

A Node-Red flow that shows a clock, day of the month and day of the week indicator. Just change the mqtt prefix.

[{"id":"18a56279.3119a6","type":"function","z":"15332f72.965b49","name":"Formata LCD","func":"const hoje = new Date()\n\nvar dia = hoje.getDate() \nvar diaDaSemana = hoje.getDay()\nvar hora = hoje.getHours()\nvar minutos = hoje.getMinutes()\nvar corDiaSemana = \"#E0E0E0\" // color for current day of the week\n\nif (diaDaSemana == 0) {\n diaDaSemana = 7 // conversion to monday starting week\n corDiaSemana = \"#FF0000\" // red mark for sunday\n}\n\n// add leading 0 to days, hours and minutes <10\nif (dia<10) {\n dia = \"0\" + dia\n}\nif (hora<10) {\n hora = \"0\" + hora\n}\nif (minutos<10) {\n minutos = \"0\" + minutos\n}\n\nmsg.payload = \n\n{\"draw\":[ \n {\"df\": [1,2,9,7, \"#FFFFFF\"]}, // draws day of month box \n {\"df\": [1,0,9,2, \"#FF0000\"]},\n \n {\"dt\": [2, 2, dia, \"#000000\"]}, // draws day of month\n {\"dt\": [13, 1, hora + \":\" + minutos, \"#FFFFFF\"]}, // draws the clock\n \n {\"dl\": [11,7,12,7, \"#666666\"]}, // draws days of week markers\n {\"dl\": [14,7,15,7, \"#666666\"]},\n {\"dl\": [17,7,18,7, \"#666666\"]},\n {\"dl\": [20,7,21,7, \"#666666\"]},\n {\"dl\": [23,7,24,7, \"#666666\"]},\n {\"dl\": [26,7,27,7, \"#666666\"]},\n {\"dl\": [29,7,30,7, \"#666666\"]},\n {\"dl\": [11+(diaDaSemana-1)*3,7,12+(diaDaSemana-1)*3,7, corDiaSemana] // draws current day of week mark\n } \n],\n \"pos\": 1,\n} \n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":349.33331298828125,"y":222.33334350585938,"wires":[["b04e8bae.ac1f"]]},{"id":"b04e8bae.ac1f","type":"mqtt out","z":"15332f72.965b49","name":"App Data e Hora","topic":"LCD_awtrix/custom/clockCalendar","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"","x":589.3333129882812,"y":222.33334350585938,"wires":[]},{"id":"593cd673.a975a","type":"inject","z":"15332f72.965b49","name":"1x/min","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"*/1 0-23 * * *","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":129.33331298828125,"y":222.33334350585938,"wires":[["18a56279.3119a6"]]},{"id":"c209003f.98044","type":"comment","z":"15332f72.965b49","name":"App para mostrar dia do mes e hora atual","info":"","x":200,"y":180,"wires":[]}]
-- Flow first published on June 27, 2023.