Skip to content

Instantly share code, notes, and snippets.

@robertsLando
Last active September 27, 2021 09:09
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save robertsLando/65f411e9e37745a4bbeef5926d052c97 to your computer and use it in GitHub Desktop.
Save robertsLando/65f411e9e37745a4bbeef5926d052c97 to your computer and use it in GitHub Desktop.
Temperature/ON-OFF Week Scheduler UI-Template Node-Red Dashboard

This allows users to set up a 24h scheduler for each day of the week in a quick and easy way.

It is a customization of Peter Scargill Thermostat Weekend so all credits goes to him.

In the Comment node you can find instructions on how to create more schedulers in the same UI, just need to copy/paste the flow of a single scheduler and find/replace the name of variables listed in the Comment node.

UI Preview

alt text

Nodes

alt text

Fixed some bugs with the original scheduler. If you have any comment or suggestions let me know.

Enjoy

[{"id":"9a2a7615.455c48","type":"ui_template","z":"90cc983a.804858","group":"9b8f575a.b741a8","name":"css etc","order":4,"width":"0","height":"0","format":"<style>\n\n.filled { height: 48px !important;padding: 0 !important; margin: 0 !important;}\n.nr-dashboard-template { padding: 0; margin: 0;}\n.rounded { border-radius: 12px 12px 12px 12px;}\n.bigfont { font-size: 18px;}\n.smallfont { font-size: 12px;}\n.thedays { cursor:pointer; vertical-align:bottom; height:48px; }\n.the2px { background-color: #9E9E9E; height:2px; }\n.theblocks {width:100%; height:0%; background-color:#4CAF50; }\n.greybuttons { background-color:#009688 !important; width:48px; border: none;}\n.thetemps { cursor:pointer; font-size:70%; color:#9E9E9E !important; }\n.smallheadings { color:white; font-size:80%; }\n\n</style>\n\n<script>\nvar current=1;\n\n$('.vibrate').on('click', function() {\n navigator.vibrate(100);\n});\n\nfunction restore_bg(x) {\n $(this).css(\"background-color\", x);\n };\n\n$('.touched').on('mousedown', function() {\n \n var x= $(this).css(\"background-color\");\n $(this).css(\"background-color\", \"yellow\");\n \n setTimeout(restore_bg.bind(this,x),50);\n navigator.vibrate(80);\n });\n \n</script>","storeOutMessages":false,"fwdInMessages":true,"x":217,"y":89,"wires":[[]]},{"id":"dfd41566.f73768","type":"ui_template","z":"90cc983a.804858","group":"9b8f575a.b741a8","name":"Settings page","order":3,"width":"6","height":"6","format":"<script>\nvar thedays=[\"DOMENICA\",\"LUNEDI\",\"MARTEDI\",\"MERCOLEDI\",\"GIOVEDI\",\"VENERDI\",\"SABATO\"];\nvar ID = \"AA\";\n\nvar last=29;\n\nfunction bar(mm,val)\n{\nif (val==14) { $(mm).height(\"12%\"); $(mm).css('background-color', '#1E88E5'); } //blue\nif (val==15) { $(mm).height(\"16%\"); $(mm).css('background-color', '#039BE5'); }\nif (val==16) { $(mm).height(\"20%\"); $(mm).css('background-color', '#00ACC1'); } \nif (val==17) { $(mm).height(\"24%\"); $(mm).css('background-color', '#039BE5'); } // cyan\nif (val==18) { $(mm).height(\"28%\"); $(mm).css('background-color', '#00ACC1'); }\nif (val==19) { $(mm).height(\"32%\"); $(mm).css('background-color', '#00897B'); } \nif (val==20) { $(mm).height(\"36%\"); $(mm).css('background-color', '#388E3C'); } // green\nif (val==21) { $(mm).height(\"40%\"); $(mm).css('background-color', '#689F38'); }\nif (val==22) { $(mm).height(\"44%\"); $(mm).css('background-color', '#C0CA33'); }\nif (val==23) { $(mm).height(\"48%\"); $(mm).css('background-color', '#FDD835'); } // yellow\nif (val==24) { $(mm).height(\"52%\"); $(mm).css('background-color', '#FBC02D'); }\nif (val==25) { $(mm).height(\"56%\"); $(mm).css('background-color', '#FFA000'); }\nif (val==26) { $(mm).height(\"60%\"); $(mm).css('background-color','#E64A19'); } // red\n \n}\n\nfunction stat(text)\n{\n$(\"#info\"+ID).text(text);\nvar tm=setTimeout(function(){ $(\"#info\"+ID).text(\"Ok\"); clearTimeout(tm);}, 3000);\n}\n\nfunction selec(val,sta)\n{\nvar w=\"#td\"+val+ID;\n if (sta) $(w).css('background-color','#4CAF50'); else $(w).css('background-color','#FFC107');\n}\n\n (function(scope){\n scope.ID = ID;\n scope.send({payload: '29'})\n scope.$watch('msg', function(msg) {\n selec(last,0); last=msg.selector; selec(last,1);\n for (var x=0; x<24; x++) \n { \n var w=\"#t\"+x+ID; bar(w,msg.timing[((msg.days-1)*24)+x]); \n var v=\"#v\"+x+ID; $(v).text(msg.timing[((msg.days-1)*24)+x]+\"°\")\n } \n for (var x=0; x<2; x++) { var w=\"#s\"+x+ID; $(w).text(msg.timing[168+x]); }\n $(\"#d0\"+ID).text(thedays[msg.days-1]);\n if ((last>4) &&(last<29))\n $(\"#current\"+ID).text(msg.timing[((msg.days-1)*24)+last-5] + \"°\");\n else\n $(\"#current\"+ID).text(\"-\");\n \n if (msg.foryou!=\"\") { stat(msg.foryou); }\n \n \n });\n \n })(scope);\n \n\n</script>\n<table width=\"100%\">\n \n <tr>\n <td colspan=24><center><span class=\"smallheadings\" >Giorno</span></center></td>\n <!--<td colspan=3><center><span class=\"smallheadings\">Clima</span></center></td>\n <td colspan=3><center><span class=\"smallheadings\">Fuori casa</span></center></td>-->\n </tr>\n \n <tr>\n <td ng-click=\"send({payload: '29'})\" colspan=24><center><span id=\"{{ 'd0' + ID }}\" style=\"cursor:pointer;color:white;font-size:120%\">LUNEDI</span></center></td>\n <!--<td ng-click=\"send({payload: '1'})\" colspan=3><center><span id=\"s0\" style=\"color:white;font-size:120%\">14</span></center></td>\n <td ng-click=\"send({payload: '2'})\" colspan=3><center><span id=\"s1\" style=\"color:white;font-size:120%\">20</span></center></td>-->\n </tr>\n \n <tr style=\"height:2px\">\n <td id=\"{{ 'td29' + ID }}\" colspan=24 style=\"background-color:#9E9E9E;height:2px;\"></td> \n <!-- <td id=\"td1\" colspan=3 style=\"background-color:#9E9E9E;height:2px;\"></td>\n <td id=\"td2\" colspan=3 style=\"background-color:#9E9E9E;height:2px;\"></td>-->\n </tr> \n\n <tr>\n <td ng-click=\"send({payload: '5'})\" class=\"thedays\"><span id=\"{{ 'v0' + ID }}\" class=\"thetemps\"></span><div id=\"{{ 't0' + ID }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '6'})\" class=\"thedays\"><span id=\"{{ 'v1' + ID }}\" class=\"thetemps\"></span><div id=\"{{ 't1' + ID }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '7'})\" class=\"thedays\"><span id=\"{{ 'v2' + ID }}\" class=\"thetemps\"></span><div id=\"{{ 't2' + ID }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '8'})\" class=\"thedays\"><span id=\"{{ 'v3' + ID }}\" class=\"thetemps\"></span><div id=\"{{ 't3' + ID }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '9'})\" class=\"thedays\"><span id=\"{{ 'v4' + ID }}\" class=\"thetemps\"></span><div id=\"{{ 't4' + ID }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '10'})\" class=\"thedays\"><span id=\"{{ 'v5' + ID }}\" class=\"thetemps\"></span><div id=\"{{ 't5' + ID }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '11'})\" class=\"thedays\"><span id=\"{{ 'v6' + ID }}\" class=\"thetemps\"></span><div id=\"{{ 't6' + ID }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '12'})\" class=\"thedays\"><span id=\"{{ 'v7' + ID }}\" class=\"thetemps\"></span><div id=\"{{ 't7' + ID }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '13'})\" class=\"thedays\"><span id=\"{{ 'v8' + ID }}\" class=\"thetemps\"></span><div id=\"{{ 't8' + ID }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '14'})\" class=\"thedays\"><span id=\"{{ 'v9' + ID }}\" class=\"thetemps\"></span><div id=\"{{ 't9' + ID }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '15'})\" class=\"thedays\"><span id=\"{{ 'v10' + ID }}\" class=\"thetemps\"></span><div id=\"{{ 't10' + ID }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '16'})\" class=\"thedays\"><span id=\"{{ 'v11' + ID }}\" class=\"thetemps\"></span><div id=\"{{ 't11' + ID }}\" class=\"theblocks\"></div></td>\n </tr> \n \n <tr style=\"height:2px\">\n <td id=\"{{ 'td5' + ID }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td6' + ID }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td7' + ID }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td8' + ID }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td9' + ID }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td10' + ID }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td11' + ID }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td12' + ID }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td13' + ID }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td14' + ID }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td15' + ID }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td16' + ID }}\" class=\"the2px\"></td>\n </tr> \n \n <tr>\n <td align=\"center\">0</td>\n <td align=\"center\">1</td>\n <td align=\"center\">2</td>\n <td align=\"center\">3</td>\n <td align=\"center\">4</td>\n <td align=\"center\">5</td>\n <td align=\"center\">6</td>\n <td align=\"center\">7</td>\n <td align=\"center\">8</td>\n <td align=\"center\">9</td>\n <td align=\"center\">10</td>\n <td align=\"center\">11</td>\n </tr> \n \n <tr>\n <td ng-click=\"send({payload: '17'})\" class=\"thedays\"><span id=\"{{ 'v12' + ID }}\" class=\"thetemps\"></span><div id=\"{{ 't12' + ID }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '18'})\" class=\"thedays\"><span id=\"{{ 'v13' + ID }}\" class=\"thetemps\"></span><div id=\"{{ 't13' + ID }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '19'})\" class=\"thedays\"><span id=\"{{ 'v14' + ID }}\" class=\"thetemps\"></span><div id=\"{{ 't14' + ID }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '20'})\" class=\"thedays\"><span id=\"{{ 'v15' + ID }}\" class=\"thetemps\"></span><div id=\"{{ 't15' + ID }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '21'})\" class=\"thedays\"><span id=\"{{ 'v16' + ID }}\" class=\"thetemps\"></span><div id=\"{{ 't16' + ID }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '22'})\" class=\"thedays\"><span id=\"{{ 'v17' + ID }}\" class=\"thetemps\"></span><div id=\"{{ 't17' + ID }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '23'})\" class=\"thedays\"><span id=\"{{ 'v18' + ID }}\" class=\"thetemps\"></span><div id=\"{{ 't18' + ID }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '24'})\" class=\"thedays\"><span id=\"{{ 'v19' + ID }}\" class=\"thetemps\"></span><div id=\"{{ 't19' + ID }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '25'})\" class=\"thedays\"><span id=\"{{ 'v20' + ID }}\" class=\"thetemps\"></span><div id=\"{{ 't20' + ID }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '26'})\" class=\"thedays\"><span id=\"{{ 'v21' + ID }}\" class=\"thetemps\"></span><div id=\"{{ 't21' + ID }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '27'})\" class=\"thedays\"><span id=\"{{ 'v22' + ID }}\" class=\"thetemps\"></span><div id=\"{{ 't22' + ID }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '28'})\" class=\"thedays\"><span id=\"{{ 'v23' + ID }}\" class=\"thetemps\"></span><div id=\"{{ 't23' + ID }}\" class=\"theblocks\"></div></td>\n </tr> \n \n <tr style=\"height:2px\">\n <td id=\"{{ 'td17' + ID }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td18' + ID }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td19' + ID }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td20' + ID }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td21' + ID }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td22' + ID }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td23' + ID }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td24' + ID }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td25' + ID }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td26' + ID }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td27' + ID }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td28' + ID }}\" class=\"the2px\"></td>\n </tr> \n \n <tr>\n <td align=\"center\">12</td>\n <td align=\"center\">13</td>\n <td align=\"center\">14</td>\n <td align=\"center\">15</td>\n <td align=\"center\">16</td>\n <td align=\"center\">17</td>\n <td align=\"center\">18</td>\n <td align=\"center\">19</td>\n <td align=\"center\">20</td>\n <td align=\"center\">21</td>\n <td align=\"center\">22</td>\n <td align=\"center\">23</td>\n </tr> \n \n <tr height=\"20px\">\n <td colspan=2 class=\"smallheadings\">Azioni:</td>\n\n <td colspan=10 ><center><span id=\"{{ 'info' + ID }}\" class=\"smallheadings\" ></span></center></td>\n\n </tr>\n \n <tr height=\"10px\">\n <td colspan=\"12\"></td>\n </tr>\n\n <tr style=\"height:48px\">\n <td colspan=2>\n <button class=\"vibrate filled touched smallfont rounded greybuttons\" ng-click=\"send({payload: 'd'})\"> \n <ng-md-icon style=\"color: #fff;\" icon=\"keyboard_arrow_down\">\n <md-tooltip md-direction=\"bottom\">DECREMENTA</md-tooltip>\n </ng-md-icon>\n </button> \n </td>\n \n <td colspan=2><center><span id=\"{{ 'current' + ID }}\" style=\"color:white;font-size:120%\">-</span></center></td>\n\n <td colspan=2>\n <button class=\"vibrate filled touched smallfont rounded greybuttons\" ng-click=\"send({payload: 'u'})\"> \n <ng-md-icon style=\"color: #fff;\" icon=\"keyboard_arrow_up\">\n <md-tooltip md-direction=\"bottom\">INCREMENTA</md-tooltip>\n </ng-md-icon>\n </button> \n </td>\n\n <td colspan=2>\n <button class=\"vibrate filled touched smallfont rounded greybuttons\" ng-click=\"send({payload: 'r'})\"> \n <ng-md-icon style=\"color: #fff;\" icon=\"content_copy\">\n <md-tooltip md-direction=\"bottom\">COPIA</md-tooltip>\n </ng-md-icon>\n </button> \n </td>\n\n\n <td colspan=2>\n <button class=\"vibrate filled touched smallfont rounded greybuttons\" ng-click=\"send({payload: 's'})\"> \n <ng-md-icon style=\"color: #fff;\" icon=\"save\">\n <md-tooltip md-direction=\"bottom\">SALVA</md-tooltip>\n </ng-md-icon>\n </button> \n </td>\n\n <td colspan=2>\n <button class=\"vibrate filled touched smallfont rounded greybuttons\" ng-click=\"send({payload: 'c'})\"> \n <ng-md-icon style=\"color: #fff;\" icon=\"cancel\">\n <md-tooltip md-direction=\"bottom\">ANNULLA</md-tooltip>\n </ng-md-icon>\n </button> \n </td>\n <td colspan=1></td>\n </tr>\n\n</table>","storeOutMessages":false,"fwdInMessages":false,"x":237,"y":126,"wires":[["97430b63.1f4c88"]]},{"id":"97430b63.1f4c88","type":"function","z":"90cc983a.804858","name":"Process controls","func":"if ( typeof context.days == 'undefined' ) context.days=1;\nif ( typeof context.selector == 'undefined' ) context.selector=29;\nif ( typeof context.saving == 'undefined' ) context.saving=1;\nif ( typeof context.global.timing == 'undefined' ) \n {\n context.global.timing=[\n 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,\n 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,\n 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,\n 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,\n 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,\n 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,\n 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,\n 6,14\n ];\n context.saving=1; \n }\nvar timing=global.get(\"timing\");\n\nswitch (msg.payload)\n {\n case \"u\" : if ((context.selector>4)&&(context.selector<29))\n {\n timing[((context.days-1)*24)+context.selector-5]++; \n if (timing[((context.days-1)*24)+context.selector-5]>26){ timing[((context.days-1)*24)+context.selector-5]=26; msg.foryou=\"Limite raggiunto\";}\n else msg.foryou=\"Temperatura aumentata\";\n }\n if (context.selector==1) { if (timing[168+(context.selector-1)]<26) { timing[168+(context.selector-1)]++; msg.foryou=\"Temperatura clima aumentata di 1°C\"; } else msg.foryou=\"Limite raggiunto\"; }\n if (context.selector==2) { if (timing[168+(context.selector-1)]<26) { timing[168+(context.selector-1)]++; msg.foryou=\"Temperatura fuori casa aumentata di 1°C\"; } else msg.foryou=\"Limite raggiunto\"; }\n if (context.selector==29) { msg.foryou=\"Giorno successivo\"; context.days++; if (context.days>7) { context.days = 1; } }\n break;\n case \"d\" : if ((context.selector>4)&&(context.selector<29))\n {\n timing[((context.days-1)*24)+context.selector-5]--; \n if (timing[((context.days-1)*24)+context.selector-5]<14){ timing[((context.days-1)*24)+context.selector-5]=14; msg.foryou=\"Limite raggiunto\";}\n else msg.foryou=\"Temperatura decrementata\";\n }\n if (context.selector==1) { if (timing[168+(context.selector-1)]>12) { timing[168+(context.selector-1)]--; msg.foryou=\"Temperatura clima diminuita di 1°C\"; } else msg.foryou=\"Limite raggiunto\"; }\n if (context.selector==2) { if (timing[168+(context.selector-1)]>12) { timing[168+(context.selector-1)]--; msg.foryou=\"Temperatura fuori casa diminuita di 1°C\"; } else msg.foryou=\"Limite raggiunto\"; }\n if (context.selector==29) { msg.foryou=\"Giorno precedente\"; context.days--; if (context.days < 1) { context.days = 7; } }\n break;\n case 'r' : if ((context.selector>=5)&&(context.selector<28))\n {\n timing[((context.days-1)*24)+context.selector-4]=timing[((context.days-1)*24)+context.selector-5]; \n context.selector++;\n msg.foryou=\"Temperatura copiata nello slot successivo\";\n }\n if ((context.selector==29)&&(context.days<7))\n {\n for (var a=0;a<24;a++)\n {\n timing[((context.days)*24)+a]=timing[((context.days-1)*24)+a]; \n }\n context.days++;\n msg.foryou=\"Impostazioni copiate nel giorno successivo\";\n }\n else if(context.days==7)\n msg.foryou=\"Fine della settimana raggiunto!\";\n break;\n case 's': context.saving=0; msg.foryou=\"Impostazioni salvate\"; break;\n case '1':\n case '2':\n case '3':\n case '4':\n case '5':\n case '6':\n case '7':\n case '8':\n case '9':\n case '10':\n case '11':\n case '12':\n case '13':\n case '14':\n case '15':\n case '16':\n case '17':\n case '18':\n case '19':\n case '20':\n case '21':\n case '22':\n case '23':\n case '24':\n case '25':\n case '26':\n case '27':\n case '28':\n case '29': context.selector=parseInt(msg.payload);\n if (msg.payload=='1') msg.foryou=\"Temperatura clima selezionata\"; \n else if (msg.payload=='2') msg.foryou=\"Temperatura fuori casa selezionata\";\n else if (msg.payload=='29') msg.foryou=\"Giorno selezionato\";\n else msg.foryou=\"Regolazione temperatura ore: \" + (parseInt(msg.payload)-5);\n break;\n case 'c' : msg.payload=\"niente\"; msg.foryou=\"Cambiamenti annullati\"; node.send([null,null,msg]);\n }\n\nmsg.temperatures=context.temperatures;\nmsg.timing=timing;\nmsg.days=context.days;\nmsg.selector=context.selector;\n\nnode.send([msg,null,null]);\n\nif (context.saving===0) \n { \n msg.topic=\"\";\n msg.timing=\"\";\n msg.payload=JSON.stringify(timing);\n node.send([null,msg,null]); \n context.saving=1;\n }\n msg.foryou=\"\"","outputs":"3","noerr":0,"x":460,"y":178,"wires":[["387461ec.dc158e"],["ac33e6d0.c163e8"],["8f477cbb.0b78c"]]},{"id":"aeaa17cd.6a07f8","type":"inject","z":"90cc983a.804858","name":"Once only","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":true,"x":245,"y":226,"wires":[["97430b63.1f4c88","94321f9f.323dc"]]},{"id":"bdc4da3.12a8028","type":"inject","z":"90cc983a.804858","name":"Every minute","topic":"","payload":"","payloadType":"str","repeat":"60","crontab":"","once":true,"x":218,"y":347,"wires":[["aaff02d9.db667"]]},{"id":"94288cf.ccce97","type":"function","z":"90cc983a.804858","name":"Process heat","func":"var timing=global.get(\"timing\");\nvar now = new Date(msg.time);\nmsg.payload=timing[(now.getDay()*24)+now.getHours()];\nmsg.frost=timing[168];\nmsg.away=timing[169];\nnode.status({fill:\"blue\",shape:\"dot\",text:\"Set point \" + msg.payload + \"°C\"});\nreturn msg;\n\n","outputs":1,"noerr":0,"x":544,"y":347,"wires":[["715747d.b57acb8"]]},{"id":"ac33e6d0.c163e8","type":"file","z":"90cc983a.804858","name":"backup","filename":"/home/pi/data/thermo_scheduler.log","appendNewline":true,"createDir":true,"overwriteFile":"true","x":649,"y":177,"wires":[]},{"id":"94321f9f.323dc","type":"file in","z":"90cc983a.804858","name":"Restore","filename":"/home/pi/data/thermo_scheduler.log","format":"utf8","x":438,"y":256,"wires":[["d9f39fdb.ade5c"]]},{"id":"d9f39fdb.ade5c","type":"function","z":"90cc983a.804858","name":"Restore data from SD","func":"context.global.timing=JSON.parse(msg.payload);\nmsg.payload=\"\";\nreturn msg;","outputs":1,"noerr":0,"x":638,"y":256,"wires":[["720ced17.741ec4"]]},{"id":"715747d.b57acb8","type":"debug","z":"90cc983a.804858","name":"","active":true,"console":"false","complete":"true","x":715.5,"y":347,"wires":[]},{"id":"db363d9e.83b29","type":"inject","z":"90cc983a.804858","name":"","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":true,"x":242,"y":1826,"wires":[["8ab4f286.9e135"]]},{"id":"8ab4f286.9e135","type":"moment","z":"90cc983a.804858","name":"","topic":"","input":"payload","inputType":"msg","inTz":"UTC","adjAmount":"2","adjType":"hours","adjDir":"add","format":"lll","locale":"it_IT","output":"payload","outputType":"msg","outTz":"UTC","x":445,"y":1826,"wires":[["1b39179f.d8dd28"]]},{"id":"1b39179f.d8dd28","type":"ui_text","z":"90cc983a.804858","group":"f0089344.b8ed1","order":0,"width":0,"height":0,"name":"","label":"","format":"{{msg.payload}}","layout":"col-center","x":636,"y":1826,"wires":[]},{"id":"b9bfb4a3.0cea48","type":"link in","z":"90cc983a.804858","name":"restore","links":["8f477cbb.0b78c"],"x":298.5,"y":277,"wires":[["94321f9f.323dc"]]},{"id":"8f477cbb.0b78c","type":"link out","z":"90cc983a.804858","name":"restore","links":["b9bfb4a3.0cea48"],"x":611.5,"y":214,"wires":[]},{"id":"acc52a0d.3759b8","type":"link in","z":"90cc983a.804858","name":"restoreSD","links":["720ced17.741ec4"],"x":298,"y":178,"wires":[["97430b63.1f4c88"]]},{"id":"720ced17.741ec4","type":"link out","z":"90cc983a.804858","name":"restoreSD","links":["acc52a0d.3759b8"],"x":792,"y":256,"wires":[]},{"id":"387461ec.dc158e","type":"link out","z":"90cc983a.804858","name":"setSettings","links":["89be7c05.e44d8"],"x":612.5,"y":138,"wires":[]},{"id":"89be7c05.e44d8","type":"link in","z":"90cc983a.804858","name":"setSettings","links":["387461ec.dc158e"],"x":104.5,"y":126,"wires":[["dfd41566.f73768"]]},{"id":"aaff02d9.db667","type":"moment","z":"90cc983a.804858","name":"time","topic":"","input":"","inputType":"date","inTz":"UTC","adjAmount":"2","adjType":"hours","adjDir":"add","format":"","locale":"it_IT","output":"time","outputType":"msg","outTz":"UTC","x":383.5,"y":347,"wires":[["94288cf.ccce97"]]},{"id":"40c5d4d9.8147ac","type":"ui_template","z":"90cc983a.804858","group":"f1a9197e.2dfc88","name":"Settings page","order":3,"width":"6","height":"6","format":"<script>\n\nvar thedays1=[\"DOMENICA\",\"LUNEDI\",\"MARTEDI\",\"MERCOLEDI\",\"GIOVEDI\",\"VENERDI\",\"SABATO\"];\n\nvar ID1 = \"BB\";\n\nvar last1=29;\n\nfunction stat1(text)\n{\n$(\"#info\"+ID1).text(text);\nvar tm=setTimeout(function(){ $(\"#info\"+ID1).text(\"Ok\"); clearTimeout(tm);}, 3000);\n}\n\nfunction selec1(val,sta)\n{\nvar w=\"#td\"+val+ID1;\n if (sta) $(w).css('background-color','#4CAF50'); else $(w).css('background-color','#FFC107');\n}\n\n\n (function(scope){\n scope.ID1 = ID1;\n scope.send({payload: '29'})\n scope.$watch('msg', function(msg) {\n selec1(last1,0); last1=msg.selector; selec1(last1,1);\n for (var x=0; x<24; x++) \n { \n var w=\"#t\"+x+ID1; bar(w,msg.timing[((msg.days-1)*24)+x]); \n var v=\"#v\"+x+ID1; $(v).text(msg.timing[((msg.days-1)*24)+x]+\"°\")\n } \n for (var x=0; x<2; x++) { var w=\"#s\"+x+ID1; $(w).text(msg.timing[168+x]); }\n $(\"#d0\"+ID1).text(thedays1[msg.days-1]);\n if ((last1>4) &&(last1<29))\n $(\"#current\"+ID1).text(msg.timing[((msg.days-1)*24)+last1-5] + \"°\");\n else\n $(\"#current\"+ID1).text(\"-\");\n \n if (msg.foryou!=\"\") { stat1(msg.foryou); }\n \n \n });\n \n })(scope);\n \n\n</script>\n<table width=\"100%\">\n \n <tr>\n <td colspan=24><center><span class=\"smallheadings\" >Giorno</span></center></td>\n <!--<td colspan=3><center><span class=\"smallheadings\">Clima</span></center></td>\n <td colspan=3><center><span class=\"smallheadings\">Fuori casa</span></center></td>-->\n </tr>\n \n <tr>\n <td ng-click=\"send({payload: '29'})\" colspan=24><center><span id=\"{{ 'd0' + ID1 }}\" style=\"cursor:pointer;color:white;font-size:120%\">LUNEDI</span></center></td>\n <!--<td ng-click=\"send({payload: '1'})\" colspan=3><center><span id=\"s0\" style=\"color:white;font-size:120%\">14</span></center></td>\n <td ng-click=\"send({payload: '2'})\" colspan=3><center><span id=\"s1\" style=\"color:white;font-size:120%\">20</span></center></td>-->\n </tr>\n \n <tr style=\"height:2px\">\n <td id=\"{{ 'td29' + ID1 }}\" colspan=24 style=\"background-color:#9E9E9E;height:2px;\"></td> \n <!-- <td id=\"td1\" colspan=3 style=\"background-color:#9E9E9E;height:2px;\"></td>\n <td id=\"td2\" colspan=3 style=\"background-color:#9E9E9E;height:2px;\"></td>-->\n </tr> \n\n <tr>\n <td ng-click=\"send({payload: '5'})\" class=\"thedays\"><span id=\"{{ 'v0' + ID1 }}\" class=\"thetemps\"></span><div id=\"{{ 't0' + ID1 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '6'})\" class=\"thedays\"><span id=\"{{ 'v1' + ID1 }}\" class=\"thetemps\"></span><div id=\"{{ 't1' + ID1 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '7'})\" class=\"thedays\"><span id=\"{{ 'v2' + ID1 }}\" class=\"thetemps\"></span><div id=\"{{ 't2' + ID1 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '8'})\" class=\"thedays\"><span id=\"{{ 'v3' + ID1 }}\" class=\"thetemps\"></span><div id=\"{{ 't3' + ID1 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '9'})\" class=\"thedays\"><span id=\"{{ 'v4' + ID1 }}\" class=\"thetemps\"></span><div id=\"{{ 't4' + ID1 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '10'})\" class=\"thedays\"><span id=\"{{ 'v5' + ID1 }}\" class=\"thetemps\"></span><div id=\"{{ 't5' + ID1 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '11'})\" class=\"thedays\"><span id=\"{{ 'v6' + ID1 }}\" class=\"thetemps\"></span><div id=\"{{ 't6' + ID1 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '12'})\" class=\"thedays\"><span id=\"{{ 'v7' + ID1 }}\" class=\"thetemps\"></span><div id=\"{{ 't7' + ID1 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '13'})\" class=\"thedays\"><span id=\"{{ 'v8' + ID1 }}\" class=\"thetemps\"></span><div id=\"{{ 't8' + ID1 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '14'})\" class=\"thedays\"><span id=\"{{ 'v9' + ID1 }}\" class=\"thetemps\"></span><div id=\"{{ 't9' + ID1 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '15'})\" class=\"thedays\"><span id=\"{{ 'v10' + ID1 }}\" class=\"thetemps\"></span><div id=\"{{ 't10' + ID1 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '16'})\" class=\"thedays\"><span id=\"{{ 'v11' + ID1 }}\" class=\"thetemps\"></span><div id=\"{{ 't11' + ID1 }}\" class=\"theblocks\"></div></td>\n </tr> \n \n <tr style=\"height:2px\">\n <td id=\"{{ 'td5' + ID1 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td6' + ID1 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td7' + ID1 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td8' + ID1 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td9' + ID1 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td10' + ID1 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td11' + ID1 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td12' + ID1 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td13' + ID1 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td14' + ID1 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td15' + ID1 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td16' + ID1 }}\" class=\"the2px\"></td>\n </tr> \n \n <tr>\n <td align=\"center\">0</td>\n <td align=\"center\">1</td>\n <td align=\"center\">2</td>\n <td align=\"center\">3</td>\n <td align=\"center\">4</td>\n <td align=\"center\">5</td>\n <td align=\"center\">6</td>\n <td align=\"center\">7</td>\n <td align=\"center\">8</td>\n <td align=\"center\">9</td>\n <td align=\"center\">10</td>\n <td align=\"center\">11</td>\n </tr> \n \n <tr>\n <td ng-click=\"send({payload: '17'})\" class=\"thedays\"><span id=\"{{ 'v12' + ID1 }}\" class=\"thetemps\"></span><div id=\"{{ 't12' + ID1 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '18'})\" class=\"thedays\"><span id=\"{{ 'v13' + ID1 }}\" class=\"thetemps\"></span><div id=\"{{ 't13' + ID1 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '19'})\" class=\"thedays\"><span id=\"{{ 'v14' + ID1 }}\" class=\"thetemps\"></span><div id=\"{{ 't14' + ID1 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '20'})\" class=\"thedays\"><span id=\"{{ 'v15' + ID1 }}\" class=\"thetemps\"></span><div id=\"{{ 't15' + ID1 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '21'})\" class=\"thedays\"><span id=\"{{ 'v16' + ID1 }}\" class=\"thetemps\"></span><div id=\"{{ 't16' + ID1 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '22'})\" class=\"thedays\"><span id=\"{{ 'v17' + ID1 }}\" class=\"thetemps\"></span><div id=\"{{ 't17' + ID1 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '23'})\" class=\"thedays\"><span id=\"{{ 'v18' + ID1 }}\" class=\"thetemps\"></span><div id=\"{{ 't18' + ID1 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '24'})\" class=\"thedays\"><span id=\"{{ 'v19' + ID1 }}\" class=\"thetemps\"></span><div id=\"{{ 't19' + ID1 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '25'})\" class=\"thedays\"><span id=\"{{ 'v20' + ID1 }}\" class=\"thetemps\"></span><div id=\"{{ 't20' + ID1 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '26'})\" class=\"thedays\"><span id=\"{{ 'v21' + ID1 }}\" class=\"thetemps\"></span><div id=\"{{ 't21' + ID1 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '27'})\" class=\"thedays\"><span id=\"{{ 'v22' + ID1 }}\" class=\"thetemps\"></span><div id=\"{{ 't22' + ID1 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '28'})\" class=\"thedays\"><span id=\"{{ 'v23' + ID1 }}\" class=\"thetemps\"></span><div id=\"{{ 't23' + ID1 }}\" class=\"theblocks\"></div></td>\n </tr> \n \n <tr style=\"height:2px\">\n <td id=\"{{ 'td17' + ID1 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td18' + ID1 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td19' + ID1 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td20' + ID1 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td21' + ID1 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td22' + ID1 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td23' + ID1 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td24' + ID1 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td25' + ID1 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td26' + ID1 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td27' + ID1 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td28' + ID1 }}\" class=\"the2px\"></td>\n </tr> \n \n <tr>\n <td align=\"center\">12</td>\n <td align=\"center\">13</td>\n <td align=\"center\">14</td>\n <td align=\"center\">15</td>\n <td align=\"center\">16</td>\n <td align=\"center\">17</td>\n <td align=\"center\">18</td>\n <td align=\"center\">19</td>\n <td align=\"center\">20</td>\n <td align=\"center\">21</td>\n <td align=\"center\">22</td>\n <td align=\"center\">23</td>\n </tr> \n \n <tr height=\"20px\">\n <td colspan=2 class=\"smallheadings\">Azioni:</td>\n\n <td colspan=10 ><center><span id=\"{{ 'info' + ID1 }}\" class=\"smallheadings\" ></span></center></td>\n\n </tr>\n \n <tr height=\"10px\">\n <td colspan=\"12\"></td>\n </tr>\n\n <tr style=\"height:48px\">\n <td colspan=2>\n <button class=\"vibrate filled touched smallfont rounded greybuttons\" ng-click=\"send({payload: 'd'})\"> \n <ng-md-icon style=\"color: #fff;\" icon=\"keyboard_arrow_down\">\n <md-tooltip md-direction=\"bottom\">DECREMENTA</md-tooltip>\n </ng-md-icon>\n </button> \n </td>\n \n <td colspan=2><center><span id=\"{{ 'current' + ID1 }}\" style=\"color:white;font-size:120%\">-</span></center></td>\n\n <td colspan=2>\n <button class=\"vibrate filled touched smallfont rounded greybuttons\" ng-click=\"send({payload: 'u'})\"> \n <ng-md-icon style=\"color: #fff;\" icon=\"keyboard_arrow_up\">\n <md-tooltip md-direction=\"bottom\">INCREMENTA</md-tooltip>\n </ng-md-icon>\n </button> \n </td>\n\n <td colspan=2>\n <button class=\"vibrate filled touched smallfont rounded greybuttons\" ng-click=\"send({payload: 'r'})\"> \n <ng-md-icon style=\"color: #fff;\" icon=\"content_copy\">\n <md-tooltip md-direction=\"bottom\">COPIA</md-tooltip>\n </ng-md-icon>\n </button> \n </td>\n\n\n <td colspan=2>\n <button class=\"vibrate filled touched smallfont rounded greybuttons\" ng-click=\"send({payload: 's'})\"> \n <ng-md-icon style=\"color: #fff;\" icon=\"save\">\n <md-tooltip md-direction=\"bottom\">SALVA</md-tooltip>\n </ng-md-icon>\n </button> \n </td>\n\n <td colspan=2>\n <button class=\"vibrate filled touched smallfont rounded greybuttons\" ng-click=\"send({payload: 'c'})\"> \n <ng-md-icon style=\"color: #fff;\" icon=\"cancel\">\n <md-tooltip md-direction=\"bottom\">ANNULLA</md-tooltip>\n </ng-md-icon>\n </button> \n </td>\n <td colspan=1></td>\n </tr>\n\n</table>","storeOutMessages":false,"fwdInMessages":false,"x":327,"y":487,"wires":[["6c91d28d.6473fc"]]},{"id":"6c91d28d.6473fc","type":"function","z":"90cc983a.804858","name":"Process controls","func":"if ( typeof context.days1 == 'undefined' ) context.days1=1;\nif ( typeof context.selector1 == 'undefined' ) context.selector1=29;\nif ( typeof context.saving1 == 'undefined' ) context.saving1=1;\nif ( typeof context.global.timing1 == 'undefined' ) \n {\n context.global.timing1=[\n 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,\n 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,\n 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,\n 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,\n 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,\n 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,\n 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,\n 6,14\n ];\n context.saving1=1; \n }\nvar timing1=global.get(\"timing1\");\n\nswitch (msg.payload)\n {\n case \"u\" : if ((context.selector1>4)&&(context.selector1<29))\n {\n timing1[((context.days1-1)*24)+context.selector1-5]++; \n if (timing1[((context.days1-1)*24)+context.selector1-5]>26){ timing1[((context.days1-1)*24)+context.selector1-5]=26; msg.foryou=\"Limite raggiunto\";}\n else msg.foryou=\"Temperatura aumentata\";\n }\n if (context.selector1==1) { if (timing1[168+(context.selector1-1)]<26) { timing1[168+(context.selector1-1)]++; msg.foryou=\"Temperatura clima aumentata di 1°C\"; } else msg.foryou=\"Limite raggiunto\"; }\n if (context.selector1==2) { if (timing1[168+(context.selector1-1)]<26) { timing1[168+(context.selector1-1)]++; msg.foryou=\"Temperatura fuori casa aumentata di 1°C\"; } else msg.foryou=\"Limite raggiunto\"; }\n if (context.selector1==29) { msg.foryou=\"Giorno successivo\"; context.days1++; if (context.days1>7) { context.days1 = 1; } }\n break;\n case \"d\" : if ((context.selector1>4)&&(context.selector1<29))\n {\n timing1[((context.days1-1)*24)+context.selector1-5]--; \n if (timing1[((context.days1-1)*24)+context.selector1-5]<14){ timing1[((context.days1-1)*24)+context.selector1-5]=14; msg.foryou=\"Limite raggiunto\";}\n else msg.foryou=\"Temperatura decrementata\";\n }\n if (context.selector1==1) { if (timing1[168+(context.selector1-1)]>12) { timing1[168+(context.selector1-1)]--; msg.foryou=\"Temperatura clima diminuita di 1°C\"; } else msg.foryou=\"Limite raggiunto\"; }\n if (context.selector1==2) { if (timing1[168+(context.selector1-1)]>12) { timing1[168+(context.selector1-1)]--; msg.foryou=\"Temperatura fuori casa diminuita di 1°C\"; } else msg.foryou=\"Limite raggiunto\"; }\n if (context.selector1==29) { msg.foryou=\"Giorno precedente\"; context.days1--; if (context.days1 < 1) { context.days1 = 7; } }\n break;\n case 'r' : if ((context.selector1>=5)&&(context.selector1<28))\n {\n timing1[((context.days1-1)*24)+context.selector1-4]=timing1[((context.days1-1)*24)+context.selector1-5]; \n context.selector1++;\n msg.foryou=\"Temperatura copiata nello slot successivo\";\n }\n if ((context.selector1==29)&&(context.days1<7))\n {\n for (var a=0;a<24;a++)\n {\n timing1[((context.days1)*24)+a]=timing1[((context.days1-1)*24)+a]; \n }\n context.days1++;\n msg.foryou=\"Impostazioni copiate nel giorno successivo\";\n }\n else if(context.days1==7)\n msg.foryou=\"Fine della settimana raggiunto!\";\n break;\n case 's': context.saving1=0; msg.foryou=\"Impostazioni salvate\"; break;\n case '1':\n case '2':\n case '3':\n case '4':\n case '5':\n case '6':\n case '7':\n case '8':\n case '9':\n case '10':\n case '11':\n case '12':\n case '13':\n case '14':\n case '15':\n case '16':\n case '17':\n case '18':\n case '19':\n case '20':\n case '21':\n case '22':\n case '23':\n case '24':\n case '25':\n case '26':\n case '27':\n case '28':\n case '29': context.selector1=parseInt(msg.payload);\n if (msg.payload=='1') msg.foryou=\"Temperatura clima selezionata\"; \n else if (msg.payload=='2') msg.foryou=\"Temperatura fuori casa selezionata\";\n else if (msg.payload=='29') msg.foryou=\"Giorno selezionato\";\n else msg.foryou=\"Regolazione temperatura ore: \" + (parseInt(msg.payload)-5);\n break;\n case 'c' : msg.payload=\"niente\"; msg.foryou=\"Cambiamenti annullati\"; node.send([null,null,msg]);\n }\n\nmsg.temperatures=context.temperatures1;\nmsg.timing=timing1;\nmsg.days=context.days1;\nmsg.selector=context.selector1;\n\nnode.send([msg,null,null]);\n\nif (context.saving1===0) \n { \n msg.topic=\"\";\n msg.timing=\"\";\n msg.payload=JSON.stringify(timing1);\n node.send([null,msg,null]); \n context.saving1=1;\n }\n msg.foryou=\"\"","outputs":"3","noerr":0,"x":550,"y":539,"wires":[["16c0ac56.9a2ed4"],["c97434d.a8464c8"],["5302156.ac6a2ec"]]},{"id":"1508de6a.35bb12","type":"inject","z":"90cc983a.804858","name":"Once only","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":true,"x":335,"y":587,"wires":[["6c91d28d.6473fc","fc5e38b7.19d788"]]},{"id":"9ef84222.f606","type":"inject","z":"90cc983a.804858","name":"Every minute","topic":"","payload":"","payloadType":"str","repeat":"60","crontab":"","once":true,"x":308,"y":708,"wires":[["4bec742d.96ebdc"]]},{"id":"cc0da780.529c58","type":"function","z":"90cc983a.804858","name":"Process heat","func":"var timing=global.get(\"timing1\");\nvar now = new Date(msg.time);\nmsg.payload=timing[(now.getDay()*24)+now.getHours()];\nmsg.frost=timing[168];\nmsg.away=timing[169];\nnode.status({fill:\"blue\",shape:\"dot\",text:\"Set point \" + msg.payload + \"°C\"});\nreturn msg;\n\n","outputs":1,"noerr":0,"x":636,"y":707,"wires":[["6664655c.f1d2ac"]]},{"id":"c97434d.a8464c8","type":"file","z":"90cc983a.804858","name":"backup","filename":"/home/pi/data/thermo_scheduler_01.log","appendNewline":true,"createDir":true,"overwriteFile":"true","x":739,"y":538,"wires":[]},{"id":"fc5e38b7.19d788","type":"file in","z":"90cc983a.804858","name":"Restore","filename":"/home/pi/data/thermo_scheduler_01.log","format":"utf8","x":528,"y":617,"wires":[["e718c2e.140e14"]]},{"id":"e718c2e.140e14","type":"function","z":"90cc983a.804858","name":"Restore data from SD","func":"context.global.timing1=JSON.parse(msg.payload);\nmsg.payload=\"\";\nreturn msg;","outputs":1,"noerr":0,"x":728,"y":617,"wires":[["e0eb3d1a.8cc7"]]},{"id":"6664655c.f1d2ac","type":"debug","z":"90cc983a.804858","name":"","active":true,"console":"false","complete":"true","x":804.5,"y":708,"wires":[]},{"id":"ef623152.281ea","type":"link in","z":"90cc983a.804858","name":"restore","links":["5302156.ac6a2ec"],"x":388.5,"y":638,"wires":[["fc5e38b7.19d788"]]},{"id":"5302156.ac6a2ec","type":"link out","z":"90cc983a.804858","name":"restore","links":["ef623152.281ea"],"x":701.5,"y":575,"wires":[]},{"id":"9b26a901.c7ff98","type":"link in","z":"90cc983a.804858","name":"restoreSD","links":["e0eb3d1a.8cc7"],"x":388,"y":539,"wires":[["6c91d28d.6473fc"]]},{"id":"e0eb3d1a.8cc7","type":"link out","z":"90cc983a.804858","name":"restoreSD","links":["9b26a901.c7ff98"],"x":882,"y":617,"wires":[]},{"id":"16c0ac56.9a2ed4","type":"link out","z":"90cc983a.804858","name":"setSettings","links":["7feeac82.1b8a14"],"x":702.5,"y":499,"wires":[]},{"id":"7feeac82.1b8a14","type":"link in","z":"90cc983a.804858","name":"setSettings","links":["16c0ac56.9a2ed4"],"x":194.5,"y":487,"wires":[["40c5d4d9.8147ac"]]},{"id":"4bec742d.96ebdc","type":"moment","z":"90cc983a.804858","name":"time","topic":"","input":"","inputType":"date","inTz":"UTC","adjAmount":"2","adjType":"hours","adjDir":"add","format":"","locale":"it_IT","output":"time","outputType":"msg","outTz":"UTC","x":473.5,"y":708,"wires":[["cc0da780.529c58"]]},{"id":"704b3b45.1f3124","type":"ui_template","z":"90cc983a.804858","group":"f59caa4c.0eb048","name":"Settings page","order":3,"width":"6","height":"6","format":"<script>\n\nvar thedays_0=[\"DOMENICA\",\"LUNEDI\",\"MARTEDI\",\"MERCOLEDI\",\"GIOVEDI\",\"VENERDI\",\"SABATO\"];\n\nvar ID_0 = \"DD\";\n\nvar last_0=29;\n\nfunction on_off(mm,val)\n{\nif (val==0) { $(mm).height(\"30%\"); $(mm).css('background-color', '#f44336'); } //green\nif (val==1) { $(mm).height(\"60%\"); $(mm).css('background-color', '#4CAF50'); } //green\n}\n\nfunction feedback(text)\n{\n$(\"#info\"+ID_0).text(text);\nvar tm=setTimeout(function(){ $(\"#info\"+ID_0).text(\"Ok\"); clearTimeout(tm);}, 3000);\n}\n\nfunction selec_0(val,sta)\n{\nvar w=\"#td\"+val+ID_0;\n if (sta) $(w).css('background-color','#4CAF50'); else $(w).css('background-color','#FFC107');\n}\n\n\n (function(scope){\n scope.ID_0 = ID_0;\n scope.send({payload: '29'})\n scope.$watch('msg', function(msg) {\n selec_0(last_0,0); last_0=msg.selector; selec_0(last_0,1);\n for (var x=0; x<24; x++) \n { \n var w=\"#t\"+x+ID_0; on_off(w,msg.timing[((msg.days-1)*24)+x]); \n var v=\"#v\"+x+ID_0; $(v).text(msg.timing[((msg.days-1)*24)+x] == 0 ? 'Off' : 'On')\n } \n for (var x=0; x<2; x++) { var w=\"#s\"+x+ID_0; $(w).text(msg.timing[168+x]); }\n $(\"#d0\"+ID_0).text(thedays_0[msg.days-1]);\n if ((last_0>4) &&(last_0<29))\n $(\"#current\"+ID_0).text(msg.timing[((msg.days-1)*24)+last_0-5] == 0 ? 'Off' : 'On');\n else\n $(\"#current\"+ID_0).text(\"-\");\n \n if (msg.foryou!=\"\") { feedback(msg.foryou); }\n \n \n });\n \n })(scope);\n \n\n</script>\n<table width=\"100%\">\n \n <tr>\n <td colspan=24><center><span class=\"smallheadings\" >Giorno</span></center></td>\n <!--<td colspan=3><center><span class=\"smallheadings\">Clima</span></center></td>\n <td colspan=3><center><span class=\"smallheadings\">Fuori casa</span></center></td>-->\n </tr>\n \n <tr>\n <td ng-click=\"send({payload: '29'})\" colspan=24><center><span id=\"{{ 'd0' + ID_0 }}\" style=\"cursor:pointer;color:white;font-size:120%\">LUNEDI</span></center></td>\n <!--<td ng-click=\"send({payload: '1'})\" colspan=3><center><span id=\"s0\" style=\"color:white;font-size:120%\">14</span></center></td>\n <td ng-click=\"send({payload: '2'})\" colspan=3><center><span id=\"s1\" style=\"color:white;font-size:120%\">20</span></center></td>-->\n </tr>\n \n <tr style=\"height:2px\">\n <td id=\"{{ 'td29' + ID_0 }}\" colspan=24 style=\"background-color:#9E9E9E;height:2px;\"></td> \n <!-- <td id=\"td1\" colspan=3 style=\"background-color:#9E9E9E;height:2px;\"></td>\n <td id=\"td2\" colspan=3 style=\"background-color:#9E9E9E;height:2px;\"></td>-->\n </tr> \n\n <tr>\n <td ng-click=\"send({payload: '5'})\" class=\"thedays\"><span id=\"{{ 'v0' + ID_0 }}\" class=\"thetemps\"></span><div id=\"{{ 't0' + ID_0 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '6'})\" class=\"thedays\"><span id=\"{{ 'v1' + ID_0 }}\" class=\"thetemps\"></span><div id=\"{{ 't1' + ID_0 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '7'})\" class=\"thedays\"><span id=\"{{ 'v2' + ID_0 }}\" class=\"thetemps\"></span><div id=\"{{ 't2' + ID_0 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '8'})\" class=\"thedays\"><span id=\"{{ 'v3' + ID_0 }}\" class=\"thetemps\"></span><div id=\"{{ 't3' + ID_0 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '9'})\" class=\"thedays\"><span id=\"{{ 'v4' + ID_0 }}\" class=\"thetemps\"></span><div id=\"{{ 't4' + ID_0 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '10'})\" class=\"thedays\"><span id=\"{{ 'v5' + ID_0 }}\" class=\"thetemps\"></span><div id=\"{{ 't5' + ID_0 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '11'})\" class=\"thedays\"><span id=\"{{ 'v6' + ID_0 }}\" class=\"thetemps\"></span><div id=\"{{ 't6' + ID_0 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '12'})\" class=\"thedays\"><span id=\"{{ 'v7' + ID_0 }}\" class=\"thetemps\"></span><div id=\"{{ 't7' + ID_0 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '13'})\" class=\"thedays\"><span id=\"{{ 'v8' + ID_0 }}\" class=\"thetemps\"></span><div id=\"{{ 't8' + ID_0 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '14'})\" class=\"thedays\"><span id=\"{{ 'v9' + ID_0 }}\" class=\"thetemps\"></span><div id=\"{{ 't9' + ID_0 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '15'})\" class=\"thedays\"><span id=\"{{ 'v10' + ID_0 }}\" class=\"thetemps\"></span><div id=\"{{ 't10' + ID_0 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '16'})\" class=\"thedays\"><span id=\"{{ 'v11' + ID_0 }}\" class=\"thetemps\"></span><div id=\"{{ 't11' + ID_0 }}\" class=\"theblocks\"></div></td>\n </tr> \n \n <tr style=\"height:2px\">\n <td id=\"{{ 'td5' + ID_0 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td6' + ID_0 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td7' + ID_0 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td8' + ID_0 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td9' + ID_0 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td10' + ID_0 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td11' + ID_0 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td12' + ID_0 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td13' + ID_0 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td14' + ID_0 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td15' + ID_0 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td16' + ID_0 }}\" class=\"the2px\"></td>\n </tr> \n \n <tr>\n <td align=\"center\">0</td>\n <td align=\"center\">1</td>\n <td align=\"center\">2</td>\n <td align=\"center\">3</td>\n <td align=\"center\">4</td>\n <td align=\"center\">5</td>\n <td align=\"center\">6</td>\n <td align=\"center\">7</td>\n <td align=\"center\">8</td>\n <td align=\"center\">9</td>\n <td align=\"center\">10</td>\n <td align=\"center\">11</td>\n </tr> \n \n <tr>\n <td ng-click=\"send({payload: '17'})\" class=\"thedays\"><span id=\"{{ 'v12' + ID_0 }}\" class=\"thetemps\"></span><div id=\"{{ 't12' + ID_0 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '18'})\" class=\"thedays\"><span id=\"{{ 'v13' + ID_0 }}\" class=\"thetemps\"></span><div id=\"{{ 't13' + ID_0 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '19'})\" class=\"thedays\"><span id=\"{{ 'v14' + ID_0 }}\" class=\"thetemps\"></span><div id=\"{{ 't14' + ID_0 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '20'})\" class=\"thedays\"><span id=\"{{ 'v15' + ID_0 }}\" class=\"thetemps\"></span><div id=\"{{ 't15' + ID_0 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '21'})\" class=\"thedays\"><span id=\"{{ 'v16' + ID_0 }}\" class=\"thetemps\"></span><div id=\"{{ 't16' + ID_0 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '22'})\" class=\"thedays\"><span id=\"{{ 'v17' + ID_0 }}\" class=\"thetemps\"></span><div id=\"{{ 't17' + ID_0 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '23'})\" class=\"thedays\"><span id=\"{{ 'v18' + ID_0 }}\" class=\"thetemps\"></span><div id=\"{{ 't18' + ID_0 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '24'})\" class=\"thedays\"><span id=\"{{ 'v19' + ID_0 }}\" class=\"thetemps\"></span><div id=\"{{ 't19' + ID_0 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '25'})\" class=\"thedays\"><span id=\"{{ 'v20' + ID_0 }}\" class=\"thetemps\"></span><div id=\"{{ 't20' + ID_0 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '26'})\" class=\"thedays\"><span id=\"{{ 'v21' + ID_0 }}\" class=\"thetemps\"></span><div id=\"{{ 't21' + ID_0 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '27'})\" class=\"thedays\"><span id=\"{{ 'v22' + ID_0 }}\" class=\"thetemps\"></span><div id=\"{{ 't22' + ID_0 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '28'})\" class=\"thedays\"><span id=\"{{ 'v23' + ID_0 }}\" class=\"thetemps\"></span><div id=\"{{ 't23' + ID_0 }}\" class=\"theblocks\"></div></td>\n </tr> \n \n <tr style=\"height:2px\">\n <td id=\"{{ 'td17' + ID_0 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td18' + ID_0 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td19' + ID_0 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td20' + ID_0 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td21' + ID_0 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td22' + ID_0 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td23' + ID_0 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td24' + ID_0 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td25' + ID_0 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td26' + ID_0 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td27' + ID_0 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td28' + ID_0 }}\" class=\"the2px\"></td>\n </tr> \n \n <tr>\n <td align=\"center\">12</td>\n <td align=\"center\">13</td>\n <td align=\"center\">14</td>\n <td align=\"center\">15</td>\n <td align=\"center\">16</td>\n <td align=\"center\">17</td>\n <td align=\"center\">18</td>\n <td align=\"center\">19</td>\n <td align=\"center\">20</td>\n <td align=\"center\">21</td>\n <td align=\"center\">22</td>\n <td align=\"center\">23</td>\n </tr> \n \n <tr height=\"20px\">\n <td colspan=2 class=\"smallheadings\">Azioni:</td>\n\n <td colspan=10 ><center><span id=\"{{ 'info' + ID_0 }}\" class=\"smallheadings\" ></span></center></td>\n\n </tr>\n \n <tr height=\"10px\">\n <td colspan=\"12\"></td>\n </tr>\n\n <tr style=\"height:48px\">\n <td colspan=2>\n <button class=\"vibrate filled touched smallfont rounded greybuttons\" ng-click=\"send({payload: 'd'})\"> \n <ng-md-icon style=\"color: #fff;\" icon=\"keyboard_arrow_down\"></ng-md-icon>\n </button> \n </td>\n \n <td colspan=2><center><span id=\"{{ 'current' + ID_0 }}\" style=\"color:white;font-size:120%\">-</span></center></td>\n\n <td colspan=2>\n <button class=\"vibrate filled touched smallfont rounded greybuttons\" ng-click=\"send({payload: 'u'})\"> \n <ng-md-icon style=\"color: #fff;\" icon=\"keyboard_arrow_up\"></ng-md-icon>\n </button> \n </td>\n\n <td colspan=2>\n <button class=\"vibrate filled touched smallfont rounded greybuttons\" ng-click=\"send({payload: 'r'})\"> \n <ng-md-icon style=\"color: #fff;\" icon=\"content_copy\">\n <md-tooltip md-direction=\"bottom\">COPIA</md-tooltip>\n </ng-md-icon>\n </button> \n </td>\n\n\n <td colspan=2>\n <button class=\"vibrate filled touched smallfont rounded greybuttons\" ng-click=\"send({payload: 's'})\"> \n <ng-md-icon style=\"color: #fff;\" icon=\"save\">\n <md-tooltip md-direction=\"bottom\">SALVA</md-tooltip>\n </ng-md-icon>\n </button> \n </td>\n\n <td colspan=2>\n <button class=\"vibrate filled touched smallfont rounded greybuttons\" ng-click=\"send({payload: 'c'})\"> \n <ng-md-icon style=\"color: #fff;\" icon=\"cancel\">\n <md-tooltip md-direction=\"bottom\">ANNULLA</md-tooltip>\n </ng-md-icon>\n </button> \n </td>\n <td colspan=1></td>\n </tr>\n\n</table>","storeOutMessages":false,"fwdInMessages":false,"x":385,"y":1322,"wires":[["bf082093.4c803"]]},{"id":"bf082093.4c803","type":"function","z":"90cc983a.804858","name":"Process controls","func":"if ( typeof context.days_0 == 'undefined' ) context.days_0=1;\nif ( typeof context.selector_0 == 'undefined' ) context.selector_0=29;\nif ( typeof context.saving_0 == 'undefined' ) context.saving_0=1;\nif ( typeof context.global.timing_0 == 'undefined' ) \n {\n context.global.timing_0=[\n 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,\n 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,\n 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,\n 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,\n 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,\n 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,\n 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,\n 6,1\n ];\n context.saving_0=1; \n }\nvar timing_0=global.get(\"timing_0\");\n\nswitch (msg.payload)\n {\n case \"u\" : if ((context.selector_0>4)&&(context.selector_0<29))\n {\n timing_0[((context.days_0-1)*24)+context.selector_0-5] = 1; \n msg.foryou=\"ON\";\n }\n if (context.selector_0==29) { msg.foryou=\"Giorno successivo\"; context.days_0++; if (context.days_0>7) { context.days_0 = 1; } }\n break;\n case \"d\" : if ((context.selector_0>4)&&(context.selector_0<29))\n {\n timing_0[((context.days_0-1)*24)+context.selector_0-5] = 0; \n msg.foryou=\"OFF\";\n }\n if (context.selector_0==29) { msg.foryou=\"Giorno precedente\"; context.days_0--; if (context.days_0 < 1) { context.days_0 = 7; } }\n break;\n case 'r' : if ((context.selector_0>=5)&&(context.selector_0<28))\n {\n timing_0[((context.days_0-1)*24)+context.selector_0-4]=timing_0[((context.days_0-1)*24)+context.selector_0-5]; \n context.selector_0++;\n msg.foryou=\"Valore copiato nello slot successivo\";\n }\n if ((context.selector_0==29)&&(context.days_0<7))\n {\n for (var a=0;a<24;a++)\n {\n timing_0[((context.days_0)*24)+a]=timing_0[((context.days_0-1)*24)+a]; \n }\n context.days_0++;\n msg.foryou=\"Impostazioni copiate nel giorno successivo\";\n }\n else if(context.days_0==7)\n msg.foryou=\"Fine della settimana raggiunto!\";\n break;\n case 's': context.saving_0=0; msg.foryou=\"Impostazioni salvate\"; break;\n case '1':\n case '2':\n case '3':\n case '4':\n case '5':\n case '6':\n case '7':\n case '8':\n case '9':\n case '10':\n case '11':\n case '12':\n case '13':\n case '1':\n case '15':\n case '16':\n case '17':\n case '18':\n case '19':\n case '20':\n case '21':\n case '22':\n case '23':\n case '24':\n case '25':\n case '26':\n case '27':\n case '28':\n case '29': context.selector_0=parseInt(msg.payload);\n if (msg.payload=='29') msg.foryou=\"Giorno selezionato\";\n else msg.foryou=\"Regolazione accensione ore: \" + (parseInt(msg.payload)-5);\n break;\n case 'c' : msg.payload=\"niente\"; msg.foryou=\"Cambiamenti annullati\"; node.send([null,null,msg]);\n }\n\nmsg.temperatures=context.temperatures_0;\nmsg.timing=timing_0;\nmsg.days=context.days_0;\nmsg.selector=context.selector_0;\n\nnode.send([msg,null,null]);\n\nif (context.saving_0===0) \n { \n msg.topic=\"\";\n msg.timing=\"\";\n msg.payload=JSON.stringify(timing_0);\n node.send([null,msg,null]); \n context.saving_0=1;\n }\n msg.foryou=\"\"","outputs":"3","noerr":0,"x":608,"y":1374,"wires":[["c6aaaa97.9d2138"],["7bdd4a33.21f714"],["464ee351.ba883c"]]},{"id":"57a2d99b.9d1e28","type":"inject","z":"90cc983a.804858","name":"Once only","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":true,"x":393,"y":1422,"wires":[["bf082093.4c803","96a337ab.9dd208"]]},{"id":"b183782e.cfa588","type":"inject","z":"90cc983a.804858","name":"Every minute","topic":"","payload":"","payloadType":"str","repeat":"60","crontab":"","once":true,"x":366,"y":1543,"wires":[["49c192d2.21910c"]]},{"id":"c2b276d.3897a88","type":"function","z":"90cc983a.804858","name":"Process heat","func":"var timing=global.get(\"timing_0\");\nvar now = new Date(msg.time);\nmsg.payload=timing[(now.getDay()*24)+now.getHours()];\nmsg.frost=timing[168];\nmsg.away=timing[169];\nnode.status({fill:\"blue\",shape:\"dot\",text: \"State: \" + msg.payload === 0 ? 'OFF' : 'ON'});\nreturn msg;\n\n","outputs":1,"noerr":0,"x":694,"y":1542,"wires":[["b7707faa.ba896"]]},{"id":"7bdd4a33.21f714","type":"file","z":"90cc983a.804858","name":"backup","filename":"/home/pi/data/on_off_scheduler.log","appendNewline":true,"createDir":true,"overwriteFile":"true","x":797,"y":1373,"wires":[]},{"id":"96a337ab.9dd208","type":"file in","z":"90cc983a.804858","name":"Restore","filename":"/home/pi/data/on_off_scheduler.log","format":"utf8","x":586,"y":1452,"wires":[["e527a20a.4449a"]]},{"id":"e527a20a.4449a","type":"function","z":"90cc983a.804858","name":"Restore data from SD","func":"context.global.timing_0=JSON.parse(msg.payload);\nmsg.payload=\"\";\nreturn msg;","outputs":1,"noerr":0,"x":786,"y":1452,"wires":[["fb292dd6.88b8d"]]},{"id":"b7707faa.ba896","type":"debug","z":"90cc983a.804858","name":"","active":true,"console":"false","complete":"true","x":863.5,"y":1542,"wires":[]},{"id":"603e1325.49d4ec","type":"link in","z":"90cc983a.804858","name":"restore","links":["464ee351.ba883c"],"x":446.5,"y":1473,"wires":[["96a337ab.9dd208"]]},{"id":"464ee351.ba883c","type":"link out","z":"90cc983a.804858","name":"restore","links":["603e1325.49d4ec"],"x":759.5,"y":1410,"wires":[]},{"id":"ee5f7e0b.b047e","type":"link in","z":"90cc983a.804858","name":"restoreSD","links":["fb292dd6.88b8d"],"x":446,"y":1374,"wires":[["bf082093.4c803"]]},{"id":"fb292dd6.88b8d","type":"link out","z":"90cc983a.804858","name":"restoreSD","links":["ee5f7e0b.b047e"],"x":940,"y":1452,"wires":[]},{"id":"c6aaaa97.9d2138","type":"link out","z":"90cc983a.804858","name":"setSettings","links":["a9ac35bc.552708"],"x":760.5,"y":1334,"wires":[]},{"id":"a9ac35bc.552708","type":"link in","z":"90cc983a.804858","name":"setSettings","links":["c6aaaa97.9d2138"],"x":252.5,"y":1322,"wires":[["704b3b45.1f3124"]]},{"id":"49c192d2.21910c","type":"moment","z":"90cc983a.804858","name":"time","topic":"","input":"","inputType":"date","inTz":"UTC","adjAmount":"2","adjType":"hours","adjDir":"add","format":"","locale":"it_IT","output":"time","outputType":"msg","outTz":"UTC","x":531.5,"y":1543,"wires":[["c2b276d.3897a88"]]},{"id":"b6d017fa.163da8","type":"ui_template","z":"90cc983a.804858","group":"236e90ca.4e1d","name":"Settings page","order":3,"width":"6","height":"6","format":"<script>\n\nvar thedays2=[\"DOMENICA\",\"LUNEDI\",\"MARTEDI\",\"MERCOLEDI\",\"GIOVEDI\",\"VENERDI\",\"SABATO\"];\n\nvar ID2 = \"CC\";\n\nvar last2=29;\n\nfunction stat2(text)\n{\n$(\"#info\"+ID2).text(text);\nvar tm=setTimeout(function(){ $(\"#info\"+ID2).text(\"Ok\"); clearTimeout(tm);}, 3000);\n}\n\nfunction selec2(val,sta)\n{\nvar w=\"#td\"+val+ID2;\n if (sta) $(w).css('background-color','#4CAF50'); else $(w).css('background-color','#FFC107');\n}\n\n\n (function(scope){\n scope.ID2 = ID2;\n scope.send({payload: '29'})\n scope.$watch('msg', function(msg) {\n selec2(last2,0); last2=msg.selector; selec2(last2,1);\n for (var x=0; x<24; x++) \n { \n var w=\"#t\"+x+ID2; bar(w,msg.timing[((msg.days-1)*24)+x]); \n var v=\"#v\"+x+ID2; $(v).text(msg.timing[((msg.days-1)*24)+x]+\"°\")\n } \n for (var x=0; x<2; x++) { var w=\"#s\"+x+ID2; $(w).text(msg.timing[168+x]); }\n $(\"#d0\"+ID2).text(thedays2[msg.days-1]);\n if ((last2>4) &&(last2<29))\n $(\"#current\"+ID2).text(msg.timing[((msg.days-1)*24)+last2-5] + \"°\");\n else\n $(\"#current\"+ID2).text(\"-\");\n \n if (msg.foryou!=\"\") { stat2(msg.foryou); }\n \n \n });\n \n })(scope);\n \n\n</script>\n<table width=\"100%\">\n \n <tr>\n <td colspan=24><center><span class=\"smallheadings\" >Giorno</span></center></td>\n <!--<td colspan=3><center><span class=\"smallheadings\">Clima</span></center></td>\n <td colspan=3><center><span class=\"smallheadings\">Fuori casa</span></center></td>-->\n </tr>\n \n <tr>\n <td ng-click=\"send({payload: '29'})\" colspan=24><center><span id=\"{{ 'd0' + ID2 }}\" style=\"cursor:pointer;color:white;font-size:120%\">LUNEDI</span></center></td>\n <!--<td ng-click=\"send({payload: '1'})\" colspan=3><center><span id=\"s0\" style=\"color:white;font-size:120%\">14</span></center></td>\n <td ng-click=\"send({payload: '2'})\" colspan=3><center><span id=\"s1\" style=\"color:white;font-size:120%\">20</span></center></td>-->\n </tr>\n \n <tr style=\"height:2px\">\n <td id=\"{{ 'td29' + ID2 }}\" colspan=24 style=\"background-color:#9E9E9E;height:2px;\"></td> \n <!-- <td id=\"td1\" colspan=3 style=\"background-color:#9E9E9E;height:2px;\"></td>\n <td id=\"td2\" colspan=3 style=\"background-color:#9E9E9E;height:2px;\"></td>-->\n </tr> \n\n <tr>\n <td ng-click=\"send({payload: '5'})\" class=\"thedays\"><span id=\"{{ 'v0' + ID2 }}\" class=\"thetemps\"></span><div id=\"{{ 't0' + ID2 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '6'})\" class=\"thedays\"><span id=\"{{ 'v1' + ID2 }}\" class=\"thetemps\"></span><div id=\"{{ 't1' + ID2 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '7'})\" class=\"thedays\"><span id=\"{{ 'v2' + ID2 }}\" class=\"thetemps\"></span><div id=\"{{ 't2' + ID2 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '8'})\" class=\"thedays\"><span id=\"{{ 'v3' + ID2 }}\" class=\"thetemps\"></span><div id=\"{{ 't3' + ID2 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '9'})\" class=\"thedays\"><span id=\"{{ 'v4' + ID2 }}\" class=\"thetemps\"></span><div id=\"{{ 't4' + ID2 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '10'})\" class=\"thedays\"><span id=\"{{ 'v5' + ID2 }}\" class=\"thetemps\"></span><div id=\"{{ 't5' + ID2 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '11'})\" class=\"thedays\"><span id=\"{{ 'v6' + ID2 }}\" class=\"thetemps\"></span><div id=\"{{ 't6' + ID2 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '12'})\" class=\"thedays\"><span id=\"{{ 'v7' + ID2 }}\" class=\"thetemps\"></span><div id=\"{{ 't7' + ID2 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '13'})\" class=\"thedays\"><span id=\"{{ 'v8' + ID2 }}\" class=\"thetemps\"></span><div id=\"{{ 't8' + ID2 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '14'})\" class=\"thedays\"><span id=\"{{ 'v9' + ID2 }}\" class=\"thetemps\"></span><div id=\"{{ 't9' + ID2 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '15'})\" class=\"thedays\"><span id=\"{{ 'v10' + ID2 }}\" class=\"thetemps\"></span><div id=\"{{ 't10' + ID2 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '16'})\" class=\"thedays\"><span id=\"{{ 'v11' + ID2 }}\" class=\"thetemps\"></span><div id=\"{{ 't11' + ID2 }}\" class=\"theblocks\"></div></td>\n </tr> \n \n <tr style=\"height:2px\">\n <td id=\"{{ 'td5' + ID2 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td6' + ID2 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td7' + ID2 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td8' + ID2 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td9' + ID2 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td10' + ID2 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td11' + ID2 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td12' + ID2 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td13' + ID2 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td14' + ID2 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td15' + ID2 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td16' + ID2 }}\" class=\"the2px\"></td>\n </tr> \n \n <tr>\n <td align=\"center\">0</td>\n <td align=\"center\">1</td>\n <td align=\"center\">2</td>\n <td align=\"center\">3</td>\n <td align=\"center\">4</td>\n <td align=\"center\">5</td>\n <td align=\"center\">6</td>\n <td align=\"center\">7</td>\n <td align=\"center\">8</td>\n <td align=\"center\">9</td>\n <td align=\"center\">10</td>\n <td align=\"center\">11</td>\n </tr> \n \n <tr>\n <td ng-click=\"send({payload: '17'})\" class=\"thedays\"><span id=\"{{ 'v12' + ID2 }}\" class=\"thetemps\"></span><div id=\"{{ 't12' + ID2 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '18'})\" class=\"thedays\"><span id=\"{{ 'v13' + ID2 }}\" class=\"thetemps\"></span><div id=\"{{ 't13' + ID2 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '19'})\" class=\"thedays\"><span id=\"{{ 'v14' + ID2 }}\" class=\"thetemps\"></span><div id=\"{{ 't14' + ID2 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '20'})\" class=\"thedays\"><span id=\"{{ 'v15' + ID2 }}\" class=\"thetemps\"></span><div id=\"{{ 't15' + ID2 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '21'})\" class=\"thedays\"><span id=\"{{ 'v16' + ID2 }}\" class=\"thetemps\"></span><div id=\"{{ 't16' + ID2 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '22'})\" class=\"thedays\"><span id=\"{{ 'v17' + ID2 }}\" class=\"thetemps\"></span><div id=\"{{ 't17' + ID2 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '23'})\" class=\"thedays\"><span id=\"{{ 'v18' + ID2 }}\" class=\"thetemps\"></span><div id=\"{{ 't18' + ID2 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '24'})\" class=\"thedays\"><span id=\"{{ 'v19' + ID2 }}\" class=\"thetemps\"></span><div id=\"{{ 't19' + ID2 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '25'})\" class=\"thedays\"><span id=\"{{ 'v20' + ID2 }}\" class=\"thetemps\"></span><div id=\"{{ 't20' + ID2 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '26'})\" class=\"thedays\"><span id=\"{{ 'v21' + ID2 }}\" class=\"thetemps\"></span><div id=\"{{ 't21' + ID2 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '27'})\" class=\"thedays\"><span id=\"{{ 'v22' + ID2 }}\" class=\"thetemps\"></span><div id=\"{{ 't22' + ID2 }}\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '28'})\" class=\"thedays\"><span id=\"{{ 'v23' + ID2 }}\" class=\"thetemps\"></span><div id=\"{{ 't23' + ID2 }}\" class=\"theblocks\"></div></td>\n </tr> \n \n <tr style=\"height:2px\">\n <td id=\"{{ 'td17' + ID2 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td18' + ID2 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td19' + ID2 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td20' + ID2 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td21' + ID2 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td22' + ID2 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td23' + ID2 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td24' + ID2 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td25' + ID2 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td26' + ID2 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td27' + ID2 }}\" class=\"the2px\"></td>\n <td id=\"{{ 'td28' + ID2 }}\" class=\"the2px\"></td>\n </tr> \n \n <tr>\n <td align=\"center\">12</td>\n <td align=\"center\">13</td>\n <td align=\"center\">14</td>\n <td align=\"center\">15</td>\n <td align=\"center\">16</td>\n <td align=\"center\">17</td>\n <td align=\"center\">18</td>\n <td align=\"center\">19</td>\n <td align=\"center\">20</td>\n <td align=\"center\">21</td>\n <td align=\"center\">22</td>\n <td align=\"center\">23</td>\n </tr> \n \n <tr height=\"20px\">\n <td colspan=2 class=\"smallheadings\">Azioni:</td>\n\n <td colspan=10 ><center><span id=\"{{ 'info' + ID2 }}\" class=\"smallheadings\" ></span></center></td>\n\n </tr>\n \n <tr height=\"10px\">\n <td colspan=\"12\"></td>\n </tr>\n\n <tr style=\"height:48px\">\n <td colspan=2>\n <button class=\"vibrate filled touched smallfont rounded greybuttons\" ng-click=\"send({payload: 'd'})\"> \n <ng-md-icon style=\"color: #fff;\" icon=\"keyboard_arrow_down\">\n <md-tooltip md-direction=\"bottom\">DECREMENTA</md-tooltip>\n </ng-md-icon>\n </button> \n </td>\n \n <td colspan=2><center><span id=\"{{ 'current' + ID2 }}\" style=\"color:white;font-size:120%\">-</span></center></td>\n\n <td colspan=2>\n <button class=\"vibrate filled touched smallfont rounded greybuttons\" ng-click=\"send({payload: 'u'})\"> \n <ng-md-icon style=\"color: #fff;\" icon=\"keyboard_arrow_up\">\n <md-tooltip md-direction=\"bottom\">INCREMENTA</md-tooltip>\n </ng-md-icon>\n </button> \n </td>\n\n <td colspan=2>\n <button class=\"vibrate filled touched smallfont rounded greybuttons\" ng-click=\"send({payload: 'r'})\"> \n <ng-md-icon style=\"color: #fff;\" icon=\"content_copy\">\n <md-tooltip md-direction=\"bottom\">COPIA</md-tooltip>\n </ng-md-icon>\n </button> \n </td>\n\n\n <td colspan=2>\n <button class=\"vibrate filled touched smallfont rounded greybuttons\" ng-click=\"send({payload: 's'})\"> \n <ng-md-icon style=\"color: #fff;\" icon=\"save\">\n <md-tooltip md-direction=\"bottom\">SALVA</md-tooltip>\n </ng-md-icon>\n </button> \n </td>\n\n <td colspan=2>\n <button class=\"vibrate filled touched smallfont rounded greybuttons\" ng-click=\"send({payload: 'c'})\"> \n <ng-md-icon style=\"color: #fff;\" icon=\"cancel\">\n <md-tooltip md-direction=\"bottom\">ANNULLA</md-tooltip>\n </ng-md-icon>\n </button> \n </td>\n <td colspan=1></td>\n </tr>\n\n</table>","storeOutMessages":false,"fwdInMessages":false,"x":354,"y":905,"wires":[["88e4a065.23fa7"]]},{"id":"88e4a065.23fa7","type":"function","z":"90cc983a.804858","name":"Process controls","func":"if ( typeof context.days2 == 'undefined' ) context.days2=1;\nif ( typeof context.selector2 == 'undefined' ) context.selector2=29;\nif ( typeof context.saving2 == 'undefined' ) context.saving2=1;\nif ( typeof context.global.timing2 == 'undefined' ) \n {\n context.global.timing2=[\n 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,\n 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,\n 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,\n 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,\n 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,\n 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,\n 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,\n 6,14\n ];\n context.saving2=1; \n }\nvar timing2=global.get(\"timing2\");\n\nswitch (msg.payload)\n {\n case \"u\" : if ((context.selector2>4)&&(context.selector2<29))\n {\n timing2[((context.days2-1)*24)+context.selector2-5]++; \n if (timing2[((context.days2-1)*24)+context.selector2-5]>26){ timing2[((context.days2-1)*24)+context.selector2-5]=26; msg.foryou=\"Limite raggiunto\";}\n else msg.foryou=\"Temperatura aumentata\";\n }\n if (context.selector2==1) { if (timing2[168+(context.selector2-1)]<26) { timing2[168+(context.selector2-1)]++; msg.foryou=\"Temperatura clima aumentata di 1°C\"; } else msg.foryou=\"Limite raggiunto\"; }\n if (context.selector2==2) { if (timing2[168+(context.selector2-1)]<26) { timing2[168+(context.selector2-1)]++; msg.foryou=\"Temperatura fuori casa aumentata di 1°C\"; } else msg.foryou=\"Limite raggiunto\"; }\n if (context.selector2==29) { msg.foryou=\"Giorno successivo\"; context.days2++; if (context.days2>7) { context.days2 = 1; } }\n break;\n case \"d\" : if ((context.selector2>4)&&(context.selector2<29))\n {\n timing2[((context.days2-1)*24)+context.selector2-5]--; \n if (timing2[((context.days2-1)*24)+context.selector2-5]<14){ timing2[((context.days2-1)*24)+context.selector2-5]=14; msg.foryou=\"Limite raggiunto\";}\n else msg.foryou=\"Temperatura decrementata\";\n }\n if (context.selector2==1) { if (timing2[168+(context.selector2-1)]>12) { timing2[168+(context.selector2-1)]--; msg.foryou=\"Temperatura clima diminuita di 1°C\"; } else msg.foryou=\"Limite raggiunto\"; }\n if (context.selector2==2) { if (timing2[168+(context.selector2-1)]>12) { timing2[168+(context.selector2-1)]--; msg.foryou=\"Temperatura fuori casa diminuita di 1°C\"; } else msg.foryou=\"Limite raggiunto\"; }\n if (context.selector2==29) { msg.foryou=\"Giorno precedente\"; context.days2--; if (context.days2 < 1) { context.days2 = 7; } }\n break;\n case 'r' : if ((context.selector2>=5)&&(context.selector2<28))\n {\n timing2[((context.days2-1)*24)+context.selector2-4]=timing2[((context.days2-1)*24)+context.selector2-5]; \n context.selector2++;\n msg.foryou=\"Temperatura copiata nello slot successivo\";\n }\n if ((context.selector2==29)&&(context.days2<7))\n {\n for (var a=0;a<24;a++)\n {\n timing2[((context.days2)*24)+a]=timing2[((context.days2-1)*24)+a]; \n }\n context.days2++;\n msg.foryou=\"Impostazioni copiate nel giorno successivo\";\n }\n else if(context.days2==7)\n msg.foryou=\"Fine della settimana raggiunto!\";\n break;\n case 's': context.saving2=0; msg.foryou=\"Impostazioni salvate\"; break;\n case '1':\n case '2':\n case '3':\n case '4':\n case '5':\n case '6':\n case '7':\n case '8':\n case '9':\n case '10':\n case '11':\n case '12':\n case '13':\n case '14':\n case '15':\n case '16':\n case '17':\n case '18':\n case '19':\n case '20':\n case '21':\n case '22':\n case '23':\n case '24':\n case '25':\n case '26':\n case '27':\n case '28':\n case '29': context.selector2=parseInt(msg.payload);\n if (msg.payload=='1') msg.foryou=\"Temperatura clima selezionata\"; \n else if (msg.payload=='2') msg.foryou=\"Temperatura fuori casa selezionata\";\n else if (msg.payload=='29') msg.foryou=\"Giorno selezionato\";\n else msg.foryou=\"Regolazione temperatura ore: \" + (parseInt(msg.payload)-5);\n break;\n case 'c' : msg.payload=\"niente\"; msg.foryou=\"Cambiamenti annullati\"; node.send([null,null,msg]);\n }\n\nmsg.temperatures=context.temperatures2;\nmsg.timing=timing2;\nmsg.days=context.days2;\nmsg.selector=context.selector2;\n\nnode.send([msg,null,null]);\n\nif (context.saving2===0) \n { \n msg.topic=\"\";\n msg.timing=\"\";\n msg.payload=JSON.stringify(timing2);\n node.send([null,msg,null]); \n context.saving2=1;\n }\n msg.foryou=\"\"","outputs":"3","noerr":0,"x":577,"y":957,"wires":[["787260d9.66ad9"],["1cf6f89b.0d45f7"],["7cc9f964.94edb8"]]},{"id":"1376f982.4b3f46","type":"inject","z":"90cc983a.804858","name":"Once only","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":true,"x":362,"y":1005,"wires":[["88e4a065.23fa7","1fa5b8d5.a8f1a7"]]},{"id":"ff3e7711.dd7228","type":"inject","z":"90cc983a.804858","name":"Every minute","topic":"","payload":"","payloadType":"str","repeat":"60","crontab":"","once":true,"x":335,"y":1126,"wires":[["4551bad1.cec7f4"]]},{"id":"d4a44a33.0d3668","type":"function","z":"90cc983a.804858","name":"Process heat","func":"var timing=global.get(\"timing2\");\nvar now = new Date(msg.time);\nmsg.payload=timing[(now.getDay()*24)+now.getHours()];\nmsg.frost=timing[168];\nmsg.away=timing[169];\nnode.status({fill:\"blue\",shape:\"dot\",text:\"Set point \" + msg.payload + \"°C\"});\nreturn msg;\n\n","outputs":1,"noerr":0,"x":663,"y":1125,"wires":[["9c47a8c8.854af8"]]},{"id":"1cf6f89b.0d45f7","type":"file","z":"90cc983a.804858","name":"backup","filename":"/home/pi/data/thermo_scheduler_02.log","appendNewline":true,"createDir":true,"overwriteFile":"true","x":766,"y":956,"wires":[]},{"id":"1fa5b8d5.a8f1a7","type":"file in","z":"90cc983a.804858","name":"Restore","filename":"/home/pi/data/thermo_scheduler_02.log","format":"utf8","x":555,"y":1035,"wires":[["5bd619d6.24d808"]]},{"id":"5bd619d6.24d808","type":"function","z":"90cc983a.804858","name":"Restore data from SD","func":"context.global.timing2=JSON.parse(msg.payload);\nmsg.payload=\"\";\nreturn msg;","outputs":1,"noerr":0,"x":755,"y":1035,"wires":[["f47b6ebc.28d9b"]]},{"id":"9c47a8c8.854af8","type":"debug","z":"90cc983a.804858","name":"","active":true,"console":"false","complete":"true","x":831.5,"y":1126,"wires":[]},{"id":"427f8802.d22818","type":"link in","z":"90cc983a.804858","name":"restore","links":["7cc9f964.94edb8"],"x":415.5,"y":1056,"wires":[["1fa5b8d5.a8f1a7"]]},{"id":"7cc9f964.94edb8","type":"link out","z":"90cc983a.804858","name":"restore","links":["427f8802.d22818"],"x":728.5,"y":993,"wires":[]},{"id":"114e243a.951acc","type":"link in","z":"90cc983a.804858","name":"restoreSD","links":["f47b6ebc.28d9b"],"x":415,"y":957,"wires":[["88e4a065.23fa7"]]},{"id":"f47b6ebc.28d9b","type":"link out","z":"90cc983a.804858","name":"restoreSD","links":["114e243a.951acc"],"x":909,"y":1035,"wires":[]},{"id":"787260d9.66ad9","type":"link out","z":"90cc983a.804858","name":"setSettings","links":["393cb66c.d9602a"],"x":729.5,"y":917,"wires":[]},{"id":"393cb66c.d9602a","type":"link in","z":"90cc983a.804858","name":"setSettings","links":["787260d9.66ad9"],"x":221.5,"y":905,"wires":[["b6d017fa.163da8"]]},{"id":"4551bad1.cec7f4","type":"moment","z":"90cc983a.804858","name":"time","topic":"","input":"","inputType":"date","inTz":"UTC","adjAmount":"2","adjType":"hours","adjDir":"add","format":"","locale":"it_IT","output":"time","outputType":"msg","outTz":"UTC","x":500.5,"y":1126,"wires":[["d4a44a33.0d3668"]]},{"id":"cccb363c.b966b8","type":"comment","z":"90cc983a.804858","name":"EDIT","info":"Settings page:\n-thedays2\n-ID2\n-last2\n-bar2\n-stat2\n-selec2\n\nProcess controls\n-days2\n-selector2\n-saving2\n-timing2\n-temperatures2\n\nRestore data from SD\n-timing2\n\nProcess heat\n-timing2\n\nBackup/Restore File read\nchange name of the file .log","x":148.5,"y":39,"wires":[]},{"id":"9b8f575a.b741a8","type":"ui_group","z":"","name":"Stat","tab":"8eef0cc0.5b1bf","order":2,"disp":false,"width":"6"},{"id":"f0089344.b8ed1","type":"ui_group","z":"","name":"Ora","tab":"8eef0cc0.5b1bf","disp":false,"width":"6"},{"id":"f1a9197e.2dfc88","type":"ui_group","z":"","name":"Stat1","tab":"8eef0cc0.5b1bf","order":1,"disp":false,"width":"6"},{"id":"f59caa4c.0eb048","type":"ui_group","z":"","name":"ON OFF scheduler","tab":"8eef0cc0.5b1bf","disp":false,"width":"6"},{"id":"236e90ca.4e1d","type":"ui_group","z":"","name":"Stat2","tab":"8eef0cc0.5b1bf","disp":false,"width":"6"},{"id":"8eef0cc0.5b1bf","type":"ui_tab","z":"","name":"Schedulers","icon":"dashboard"}]
@Paul-Reed
Copy link

Paul-Reed commented Mar 28, 2017

Nice work Daniel!
Much prefer the icons to Pete's images.
How do you edit the 'frost' setting, or 'away'?
It would be a nice feature if there was a 'timeout' after which the view was returned to the current day & time, so if for example, users wanted to increase the current temperature, they would not have to scroll through the days, and then select the time. They would be pre-selected by default.
Also, a minor issue, but node.status({fill:"blue",shape:"dot",text: "State: " + msg.payload === 0 ? 'OFF' : 'ON'}); always displays 'ON'.
Thanks for sharing.

Paul

@mpdk
Copy link

mpdk commented Apr 9, 2017

Great work, just one problem other than the one described by Paul-Reed
The 9 hour on the scheduler doesn't work, when you try to change it, it changes the last thing you changed instead.
But nice work

@MaxRei-dev
Copy link

Hi,
to fix the 9 hour problem. Just edit line 68 in Process controls. (should be 14 not 1).
And yes Daniel. Thanks for sharing. greate work.

@gojac
Copy link

gojac commented May 8, 2017

Hi,
When I try to change settings of ON_OFF_scheduler for current hour it doesn't work.

@robertsLando
Copy link
Author

Sorry guys I didn't received any notification of your messages. Anyway I have an updated version of these I will post it soon, this one is old and bugged.

@robertsLando
Copy link
Author

@Paul-Reed I have disabled the function Away-Frost because I didn't need it. It is commented in the code but I have removed it in my new version.

@onire77
Copy link

onire77 commented Nov 12, 2017

Hi,
I imported the flow, but it tells me "unknown moment", I tried to replace the word word with the word delay in the json file, but I think it does not work. I have node red v0.17.5. What should I do?

@robertsLando
Copy link
Author

@onire77 You have to add node-red-contrib-moment to node-red.

cd ~/.node-red
npm install node-red-contrib-moment

@giangi007
Copy link

Hi, I copy and paste the flow in the node red, but I obtain Unknow: ui_template. Could you help me to resolve this?
Thanks

@thermoguy
Copy link

I need to modify the temperature settings from Celcius to Fahrenheit. Is there a number, or formula I can change? Please advise.

@beppexx80
Copy link

Hi, now is 27/09/2021 Monday, the scheduler start payload is temperature the Sunday, why?
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment