[{"id":"8be635ca.03e038","type":"ui_template","z":"c552e8d2.712b48","group":"37f2a2e2.88cc6e","name":"css etc","order":4,"width":"0","height":"0","format":"<style>\n .filled { \n height: 100% !important;\n\n padding: 0 !important;\n margin: 0 !important;\n }\n .nr-dashboard-template {\n padding: 0;\n margin: 0;\n }\n \n .rounded {\n border-radius: 12px 12px 12px 12px;\n}\n \n .bigfont {\n font-size: 18px;\n}\n\n .smallfont {\n font-size: 12px;\n}\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":true,"fwdInMessages":true,"x":280,"y":100,"wires":[[]]},{"id":"8815a1ed.fca9b","type":"ui_template","z":"c552e8d2.712b48","group":"37f2a2e2.88cc6e","name":"Settings page","order":3,"width":"6","height":"6","format":"<style>\n.thedays { vertical-align:bottom; height:48px; }\n.the2px { background-color:black; height:2px; }\n.theblocks {width:100%; height:0%; background-color:green; }\n.greybuttons { background-color:#dddddd !important; width:48px; }\n.thetemps { font-size:70%; color:#888888 !important; }\n.smallheadings { color:black; font-size:80%; }\n\n</style>\n\n<script>\nvar thedays=[\"SUNDAY\",\"MONDAY\",\"TUESDAY\",\"WEDNESDAY\",\"THURSDAY\",\"FRIDAY\",\"SATURDAY\"];\n\nvar last=1;\n\nfunction bar(mm,val)\n{\nif (val==14) { $(mm).height(\"12%\"); $(mm).css('background-color', '#0000ff'); } //blue\nif (val==15) { $(mm).height(\"16%\"); $(mm).css('background-color', '#0055ff'); }\nif (val==16) { $(mm).height(\"20%\"); $(mm).css('background-color', '#00aaff'); } \nif (val==17) { $(mm).height(\"24%\"); $(mm).css('background-color', '#00dddd'); } // cyan\nif (val==18) { $(mm).height(\"28%\"); $(mm).css('background-color', '#00ffaa'); }\nif (val==19) { $(mm).height(\"32%\"); $(mm).css('background-color', '#00ff55'); } \nif (val==20) { $(mm).height(\"36%\"); $(mm).css('background-color', '#00ff00'); } // green\nif (val==21) { $(mm).height(\"40%\"); $(mm).css('background-color', '#55ff00'); }\nif (val==22) { $(mm).height(\"44%\"); $(mm).css('background-color', '#aaff00'); }\nif (val==23) { $(mm).height(\"48%\"); $(mm).css('background-color', '#dddd00'); } // yellow\nif (val==24) { $(mm).height(\"52%\"); $(mm).css('background-color', '#ffaa00'); }\nif (val==25) { $(mm).height(\"56%\"); $(mm).css('background-color', '#ff5500'); }\nif (val==26) { $(mm).height(\"60%\"); $(mm).css('background-color','#ff0000'); } // red\n \n}\n\nfunction stat(text)\n{\n$(\"#info\").text(text);\nvar tm=setTimeout(function(){ $(\"#info\").text(\"Ok\"); clearTimeout(tm);}, 3000);\n}\n\nfunction selec(val,sta)\n{\nvar w=\"#td\"+val;\n if (sta) $(w).css('background-color','magenta'); else $(w).css('background-color','black');\n}\n\n (function(scope){\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; bar(w,msg.timing[((msg.days-1)*24)+x]); \n var v=\"#v\"+x; $(v).text(msg.timing[((msg.days-1)*24)+x]+\"c\")\n } \n for (var x=0; x<2; x++) { var w=\"#s\"+x; $(w).text(msg.timing[168+x]); }\n $(\"#d0\").text(thedays[msg.days-1]);\n if ((last>4) &&(last<29))\n $(\"#current\").text(msg.timing[((msg.days-1)*24)+last-5] + \"c\");\n else\n $(\"#current\").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=6><center><span class=\"smallheadings\" >Day</span></center></td>\n <td colspan=3><center><span class=\"smallheadings\">Frost</span></center></td>\n <td colspan=3><center><span class=\"smallheadings\">Away</span></center></td>\n </tr>\n \n <tr>\n <td ng-click=\"send({payload: '29'})\" colspan=6><center><span id=\"d0\" style=\"color:blue;font-size:120%\">MONDAY</span></center></td>\n <td ng-click=\"send({payload: '1'})\" colspan=3><center><span id=\"s0\" style=\"color:blue;font-size:120%\">14</span></center></td>\n <td ng-click=\"send({payload: '2'})\" colspan=3><center><span id=\"s1\" style=\"color:blue;font-size:120%\">20</span></center></td>\n </tr>\n \n <tr style=\"height:2px\">\n <td id=\"td29\" colspan=6 style=\"background-color:black;height:2px;\"></td> \n <td id=\"td1\" colspan=3 style=\"background-color:black;height:2px;\"></td>\n <td id=\"td2\" colspan=3 style=\"background-color:black;height:2px;\"></td>\n </tr> \n\n <tr>\n <td ng-click=\"send({payload: '5'})\" class=\"thedays\"><span id=\"v0\" class=\"thetemps\"></span><div id=\"t0\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '6'})\" class=\"thedays\"><span id=\"v1\" class=\"thetemps\"></span><div id=\"t1\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '7'})\" class=\"thedays\"><span id=\"v2\" class=\"thetemps\"></span><div id=\"t2\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '8'})\" class=\"thedays\"><span id=\"v3\" class=\"thetemps\"></span><div id=\"t3\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '9'})\" class=\"thedays\"><span id=\"v4\" class=\"thetemps\"></span><div id=\"t4\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '10'})\" class=\"thedays\"><span id=\"v5\" class=\"thetemps\"></span><div id=\"t5\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '11'})\" class=\"thedays\"><span id=\"v6\" class=\"thetemps\"></span><div id=\"t6\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '12'})\" class=\"thedays\"><span id=\"v7\" class=\"thetemps\"></span><div id=\"t7\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '13'})\" class=\"thedays\"><span id=\"v8\" class=\"thetemps\"></span><div id=\"t8\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '14'})\" class=\"thedays\"><span id=\"v9\" class=\"thetemps\"></span><div id=\"t9\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '15'})\" class=\"thedays\"><span id=\"v10\" class=\"thetemps\"></span><div id=\"t10\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '16'})\" class=\"thedays\"><span id=\"v11\" class=\"thetemps\"></span><div id=\"t11\" class=\"theblocks\"></div></td>\n </tr> \n \n <tr style=\"height:2px\">\n <td id=\"td5\" class=\"the2px\"></td>\n <td id=\"td6\" class=\"the2px\"></td>\n <td id=\"td7\" class=\"the2px\"></td>\n <td id=\"td8\" class=\"the2px\"></td>\n <td id=\"td9\" class=\"the2px\"></td>\n <td id=\"td10\" class=\"the2px\"></td>\n <td id=\"td11\" class=\"the2px\"></td>\n <td id=\"td12\" class=\"the2px\"></td>\n <td id=\"td13\" class=\"the2px\"></td>\n <td id=\"td14\" class=\"the2px\"></td>\n <td id=\"td15\" class=\"the2px\"></td>\n <td id=\"td16\" class=\"the2px\"></td>\n </tr> \n \n <tr>\n <td>0</td>\n <td>1</td>\n <td>2</td>\n <td>3</td>\n <td>4</td>\n <td>5</td>\n <td>6</td>\n <td>7</td>\n <td>8</td>\n <td>9</td>\n <td>10</td>\n <td>11</td>\n </tr> \n \n <tr>\n <td ng-click=\"send({payload: '17'})\" class=\"thedays\"><span id=\"v12\" class=\"thetemps\"></span><div id=\"t12\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '18'})\" class=\"thedays\"><span id=\"v13\" class=\"thetemps\"></span><div id=\"t13\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '19'})\" class=\"thedays\"><span id=\"v14\" class=\"thetemps\"></span><div id=\"t14\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '20'})\" class=\"thedays\"><span id=\"v15\" class=\"thetemps\"></span><div id=\"t15\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '21'})\" class=\"thedays\"><span id=\"v16\" class=\"thetemps\"></span><div id=\"t16\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '22'})\" class=\"thedays\"><span id=\"v17\" class=\"thetemps\"></span><div id=\"t17\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '23'})\" class=\"thedays\"><span id=\"v18\" class=\"thetemps\"></span><div id=\"t18\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '24'})\" class=\"thedays\"><span id=\"v19\" class=\"thetemps\"></span><div id=\"t19\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '25'})\" class=\"thedays\"><span id=\"v20\" class=\"thetemps\"></span><div id=\"t20\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '26'})\" class=\"thedays\"><span id=\"v21\" class=\"thetemps\"></span><div id=\"t21\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '27'})\" class=\"thedays\"><span id=\"v22\" class=\"thetemps\"></span><div id=\"t22\" class=\"theblocks\"></div></td>\n <td ng-click=\"send({payload: '28'})\" class=\"thedays\"><span id=\"v23\" class=\"thetemps\"></span><div id=\"t23\" class=\"theblocks\"></div></td>\n </tr> \n \n <tr style=\"height:2px\">\n <td id=\"td17\" class=\"the2px\"></td>\n <td id=\"td18\" class=\"the2px\"></td>\n <td id=\"td19\" class=\"the2px\"></td>\n <td id=\"td20\" class=\"the2px\"></td>\n <td id=\"td21\" class=\"the2px\"></td>\n <td id=\"td22\" class=\"the2px\"></td>\n <td id=\"td23\" class=\"the2px\"></td>\n <td id=\"td24\" class=\"the2px\"></td>\n <td id=\"td25\" class=\"the2px\"></td>\n <td id=\"td26\" class=\"the2px\"></td>\n <td id=\"td27\" class=\"the2px\"></td>\n <td id=\"td28\" class=\"the2px\"></td>\n </tr> \n \n <tr>\n <td>12</td>\n <td>13</td>\n <td>14</td>\n <td>15</td>\n <td>16</td>\n <td>17</td>\n <td>18</td>\n <td>19</td>\n <td>20</td>\n <td>21</td>\n <td>22</td>\n <td>23</td>\n </tr> \n \n <tr height=\"20px\">\n <td colspan=2 bgcolor=\"#dddddd\" class=\"smallheadings\">Status:</td>\n\n <td colspan=10 bgcolor=\"#dddddd\"><center><span id=\"info\" class=\"smallheadings\" >Ok</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 <md-button class=\"vibrate filled touched smallfont rounded greybuttons\" ng-click=\"send({payload: 'd'})\"> \n <img style=\"outline : none;\" \n ng-src=\"{{(msg.payload)?'/myicons/png/48x48/actions/arrow-left-double-2.png':'/myicons/png/48x48/actions/arrow-left-double-2.png'}}\" \n height=\"36px\"\n />\n </md-button> \n </td>\n \n <td colspan=2><center><span id=\"current\" style=\"color:black;font-size:120%\">-</span></center></td>\n\n <td colspan=2>\n <md-button class=\"vibrate filled touched smallfont rounded greybuttons\" ng-click=\"send({payload: 'u'})\"> \n <img style=\"outline : none;\" \n ng-src=\"{{(msg.payload)?'/myicons/png/48x48/actions/arrow-right-double-2.png':'/myicons/png/48x48/actions/arrow-right-double-2.png'}}\" \n height=\"36px\"\n />\n </md-button> \n </td>\n\n <td colspan=2>\n <md-button class=\"vibrate filled touched smallfont rounded greybuttons\" ng-click=\"send({payload: 'r'})\"> \n <img style=\"outline : none;\" \n ng-src=\"{{(msg.payload)?'/myicons/png/48x48/actions/edit-copy-4.png':'/myicons/png/48x48/actions/edit-copy-4.png'}}\" \n height=\"36px\"\n />\n </md-button> \n </td>\n\n\n <td colspan=2>\n <md-button class=\"vibrate filled touched smallfont rounded greybuttons\" ng-click=\"send({payload: 's'})\"> \n <img style=\"outline : none;\" \n ng-src=\"{{(msg.payload)?'/myicons/png/48x48/actions/document-save-5.png':'/myicons/png/48x48/actions/document-save-5.png'}}\" \n height=\"36px\"\n />\n </md-button> \n </td>\n\n <td colspan=2>\n <md-button class=\"vibrate filled touched smallfont rounded greybuttons\" ng-click=\"send({payload: 'c'})\"> \n <img style=\"outline : none;\" \n ng-src=\"{{(msg.payload)?'/myicons/png/48x48/actions/dialog-cancel-5.png':'/myicons/png/48x48/actions/dialog-cancel-5.png'}}\" \n height=\"36px\"\n />\n </md-button> \n </td>\n <td colspan=1></td>\n </tr>\n\n</table>","storeOutMessages":false,"fwdInMessages":false,"x":500,"y":100,"wires":[["aba7c9ce.0b6c28"]]},{"id":"aba7c9ce.0b6c28","type":"function","z":"c552e8d2.712b48","name":"Process controls","func":"if ( typeof context.days == 'undefined' ) context.days=1;\nif ( typeof context.selector == 'undefined' ) context.selector=1;\nif ( typeof context.saving == 'undefined' ) context.saving=0;\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=0; \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;\n msg.foryou=\"Incremented temperature\";\n }\n if (context.selector==1) { if (timing[168+(context.selector-1)]<26) { timing[168+(context.selector-1)]++; msg.foryou=\"Incremented frost setting 1 degree\"; } else msg.foryou=\"Hit limit\"; }\n if (context.selector==2) { if (timing[168+(context.selector-1)]<26) { timing[168+(context.selector-1)]++; msg.foryou=\"Incremented away setting 1 degree\"; } else msg.foryou=\"Hit limit\"; }\n if (context.selector==29) { if (context.days<7) { context.days++; msg.foryou=\"Forward one day\";} else msg.foryou=\"End of days!!\"; }\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;\n msg.foryou=\"Decremented temperature\";\n }\n if (context.selector==1) { if (timing[168+(context.selector-1)]>12) { timing[168+(context.selector-1)]--; msg.foryou=\"Decremented frost setting 1 degree\"; } else msg.foryou=\"Hit limit\"; }\n if (context.selector==2) { if (timing[168+(context.selector-1)]>12) { timing[168+(context.selector-1)]--; msg.foryou=\"Decremented away setting 1 degree\"; } else msg.foryou=\"Hit limit\"; }\n if (context.selector==29) { if (context.days>1) { context.days--; msg.foryou=\"Backward one day\";} else msg.foryou=\"Beginning of days!!\"; }\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=\"Copied settings to the next hour slot\";\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=\"Copied a complete day's settings\";\n }\n break;\n case 's': context.saving=0; msg.foryou=\"Settings saved to disk\"; 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=\"Frost temperature selection\"; \n else if (msg.payload=='2') msg.foryou=\"Away temperature selection\";\n else if (msg.payload=='29') msg.foryou=\"Day selection\";\n else msg.foryou=\"Selected hour period \" + (parseInt(msg.payload)-4);\n break;\n case 'c' : msg.payload=\"anything\"; msg.foryou=\"Changes cancelled\"; 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":510,"y":159,"wires":[["8815a1ed.fca9b"],["9f13095d.38ba18"],["8421f1bf.f6286"]]},{"id":"945f3b38.6cc9c8","type":"inject","z":"c552e8d2.712b48","name":"Once only","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":true,"x":280,"y":160,"wires":[["aba7c9ce.0b6c28","8421f1bf.f6286"]]},{"id":"13c303be.55f94c","type":"inject","z":"c552e8d2.712b48","name":"Every minute","topic":"","payload":"","payloadType":"str","repeat":"60","crontab":"","once":false,"x":300,"y":220,"wires":[["7f0331f4.5b289"]]},{"id":"7f0331f4.5b289","type":"function","z":"c552e8d2.712b48","name":"Process heat","func":"var timing=global.get(\"timing\");\nvar now = new Date();\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":490,"y":220,"wires":[[]]},{"id":"9f13095d.38ba18","type":"file","z":"c552e8d2.712b48","name":"backup","filename":"/home/pi/petesstatlog.log","appendNewline":true,"createDir":true,"overwriteFile":"true","x":720,"y":160,"wires":[]},{"id":"8421f1bf.f6286","type":"file in","z":"c552e8d2.712b48","name":"Restore","filename":"/home/pi/petesstatlog.log","format":"utf8","x":320,"y":280,"wires":[["5efea5f0.dec25c"]]},{"id":"5efea5f0.dec25c","type":"function","z":"c552e8d2.712b48","name":"Restore data from SD","func":"context.global.timing=JSON.parse(msg.payload);\nmsg.payload=\"\";\nreturn msg;","outputs":1,"noerr":0,"x":520,"y":280,"wires":[["aba7c9ce.0b6c28"]]},{"id":"37f2a2e2.88cc6e","type":"ui_group","z":"","name":"Stat","tab":"c675fdae.9cea1","disp":false,"width":"6"},{"id":"c675fdae.9cea1","type":"ui_tab","z":"","name":"Stat","icon":"dashboard"}]
I'm so grateful you took the time to write this. It helped me a lot in my work study. Play game bou's revenge free.