So, things have gone well and I have managed to get some more time!
I have to drive my Diverter Valve 'manually' due to the way the boiler was plumbed in, so I still need NR to control the valve. Early days, but a flow was created that has access to five Profile files, these are on the same computer as NR and from here you can download the files both to the TRV and the running profile for NR so that the setpoint can be extracted. This can then be used the same as it has been,in the past - simple comparison >=<
[{"id":"0e47621e9ad92442","type":"comment","z":"0d80ab0dc9580192","name":"http://172.27.123.251/settings/thermostats/0?schedule_profile=1&schedule_rules=0600-0123456-20, 1000-0123456-19, 1500-0123456-21, 1800-0123456-22, 2100-0123456-16","info":"","x":860,"y":40,"wires":[]},{"id":"e55ff2a0097c1601","type":"comment","z":"0d80ab0dc9580192","name":"filepath","info":"// file path with / at the end\nvar filepath = \"/mnt/array1/NodeRed/AutoBackups/\"; // This is the path\nvar localfilepath = \"/home/pi/node-red-storage/\";\n//\"220129_nodered_backup.zip\"","x":370,"y":180,"wires":[]},{"id":"d22324c7f6658b15","type":"inject","z":"0d80ab0dc9580192","name":"","props":[{"p":"filename","v":"Profile1.csv","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"1","topic":"","x":170,"y":60,"wires":[["236e0b92934aa646"]]},{"id":"236e0b92934aa646","type":"file in","z":"0d80ab0dc9580192","name":"Profile","filename":"filename","filenameType":"msg","format":"utf8","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":350,"y":220,"wires":[["2c5e99851d92fd90"]]},{"id":"2c5e99851d92fd90","type":"csv","z":"0d80ab0dc9580192","name":"","sep":",","hdrin":false,"hdrout":"none","multi":"mult","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":470,"y":220,"wires":[["79c4935ebc75c29b"]]},{"id":"2a17101cae4bbbb2","type":"function","z":"0d80ab0dc9580192","name":"Frost/Shower Temps","func":"global.set('tempFrost', 14);\nglobal.set('tempHWAway', 22);\nglobal.set('tempShower', 42); \nglobal.set('tempBoilerDesired', 52);","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":620,"y":100,"wires":[[]]},{"id":"7c1c4aa16c5ea0de","type":"inject","z":"0d80ab0dc9580192","d":true,"name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"0.7","topic":"","payload":"","payloadType":"date","x":430,"y":100,"wires":[["2a17101cae4bbbb2"]]},{"id":"79c4935ebc75c29b","type":"function","z":"0d80ab0dc9580192","name":"split file","func":"global.set('profileCurrent', msg.payload[0].col1, \"storeInFile\");\nglobal.set('profileName', msg.payload[1].col1, \"storeInFile\");\n\nlet length = msg.payload.length;\nlet arr = msg.payload.slice(2)\nglobal.set('profileEvents', arr);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":600,"y":220,"wires":[["a62630aa5523a604","1f06132e71a9db59"]]},{"id":"a62630aa5523a604","type":"debug","z":"0d80ab0dc9580192","name":"debug 118","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":690,"y":180,"wires":[]},{"id":"1f06132e71a9db59","type":"function","z":"0d80ab0dc9580192","name":"set CH time/deg/days","func":"let eventTime;\nlet eventTemp;\nlet eventDays;\nlet length;\nlet eventString = \"\";\nlet arr = msg.payload;\n\nlet profileNumber = arr[0].col1;\nlet profileName = arr[1].col1;\n\nfor (let i = 2; i < arr.length; i++) {\n eventTime = arr[i].col1;\n //eventTime = eventTime.toString();\n eventTemp = arr[i].col2;\n eventDays = arr[i].col3;\n eventString = eventString + eventTime + \"-\" + eventDays + \"-\" + eventTemp\n if (i < arr.length){\n eventString = eventString + \",\";\n }\n}\n\nlet messageString = \"http://172.27.123.251/settings/thermostats/0?schedule_profile=\" + profileNumber + \"&profile_name=\" + profileName + \"&schedule_rules=\" + eventString\nmsg.url = messageString;\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":800,"y":220,"wires":[["1ab3183c161818fc","027cbeba6b1c6284"]]},{"id":"1ab3183c161818fc","type":"debug","z":"0d80ab0dc9580192","name":"debug 120","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":890,"y":180,"wires":[]},{"id":"027cbeba6b1c6284","type":"http request","z":"0d80ab0dc9580192","name":"","method":"GET","ret":"txt","paytoqs":false,"url":"","persist":false,"insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":1010,"y":220,"wires":[["be0d47aade8f41b7","2a322bc99fb6d87c"]]},{"id":"be0d47aade8f41b7","type":"debug","z":"0d80ab0dc9580192","name":"debug 121","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1090,"y":180,"wires":[]},{"id":"cef284c5dcd4dac6","type":"inject","z":"0d80ab0dc9580192","name":"","props":[{"p":"filename","v":"Profile2.csv","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"1","topic":"","x":170,"y":100,"wires":[["236e0b92934aa646"]]},{"id":"8d13df490a229a0a","type":"inject","z":"0d80ab0dc9580192","name":"","props":[{"p":"filename","v":"Profile3.csv","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"1","topic":"","x":170,"y":140,"wires":[["236e0b92934aa646"]]},{"id":"4740aa084ccf5b56","type":"inject","z":"0d80ab0dc9580192","name":"","props":[{"p":"filename","v":"Profile4.csv","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"1","topic":"","x":170,"y":180,"wires":[["236e0b92934aa646"]]},{"id":"78bd9619fe660f2e","type":"inject","z":"0d80ab0dc9580192","name":"","props":[{"p":"filename","v":"Profile5.csv","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"1","topic":"","x":170,"y":220,"wires":[["236e0b92934aa646"]]},{"id":"347f7f877f9020c9","type":"catch","z":"0d80ab0dc9580192","name":"","scope":null,"uncaught":false,"x":1080,"y":80,"wires":[["1835d45f1fd96af9"]]},{"id":"1835d45f1fd96af9","type":"debug","z":"0d80ab0dc9580192","name":"debug 98","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1220,"y":80,"wires":[]},{"id":"2a322bc99fb6d87c","type":"function","z":"0d80ab0dc9580192","name":"set CH time/deg/days","func":"delete msg.payload;\ndelete msg.topic;\ndelete msg.filename;\ndelete msg.columns;\n\nlet length;\nlet setHours;\nlet setMinutes;\nlet eventTime;\nlet timeEvent;\nlet arr = [];\narr = global.get('profileEvents');\nlet tempDesired = 27 || 0;\n\n//Get current day start and end timestamp\nlet dateNow = Date.now();\nlet timeFrom = new Date(dateNow).setHours(0, 0, 0, 0);\nlet timeTo = new Date(dateNow).setHours(23, 59, 59, 0)\n\n//Add offset, iterate until file time < current time\nfor (let i = arr.length - 1; i >= 0; i--) {\n eventTime = arr[i].col1;\n eventTime = eventTime.toString();\n msg.test1 = eventTime;\n setHours = eventTime.slice(0, 2);\n setMinutes = eventTime.slice(2);\n timeEvent = new Date(timeFrom).setHours(setHours, setMinutes, 0, 0); //Date from midnight this morning\n tempDesired = parseFloat(arr[i].col2);\n msg.tempDesired = tempDesired;\n msg.dateNow = dateNow;\n msg.timeEvent = timeEvent;\n\n if (dateNow > timeEvent) {\n global.set('tempDesiredCH', tempDesired, 'storeInFile');\n node.status({ text: timeEvent + \" | \" + tempDesired });\n return msg;\n }\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":280,"wires":[["c5980b7598462543"]]},{"id":"c5980b7598462543","type":"debug","z":"0d80ab0dc9580192","name":"debug 119","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":590,"y":280,"wires":[]},{"id":"9dfc059a6c2db66a","type":"inject","z":"0d80ab0dc9580192","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":280,"wires":[["2a322bc99fb6d87c"]]}]
Profiles.zip.txt (1.1 KB)
The profile is only loaded once and also goes to global.context. The times and setpoint are then extracted along with the current time and the setpoint set appropriately.
Comments/coding advice welcome!