[{"id":"20c7e42d04a89526","type":"tab","label":"REVISED-Charge Copy","disabled":false,"info":"This Flow controls the house energy source PV/Grid\n\nGen-AutoStart On/Off\nThis function determines whether the Generator Autostart is active or disabled subject to predetermined battery SOC%\n\n\nHouse to grid On/Off\nThis function controls am MQTT relay which, acting on the Tranfer Switch, disconnects the House consumer from the PV energy and connects it to the Grid","env":[]},{"id":"4038995ba39be0cb","type":"victron-output-generator","z":"20c7e42d04a89526","d":true,"service":"com.victronenergy.generator/0","path":"/ManualStart","serviceObj":{"service":"com.victronenergy.generator/0","name":"Generator start/stop"},"pathObj":{"path":"/ManualStart","type":"enum","name":"Manual Start","enum":{"0":"Stop generator","1":"Start generator"},"mode":"both"},"name":"","onlyChanges":false,"x":980,"y":80,"wires":[],"info":"# Generator start stop manual"},{"id":"521b0cd1cf680b1f","type":"victron-input-battery","z":"20c7e42d04a89526","d":true,"service":"com.victronenergy.battery/0","path":"/Soc","serviceObj":{"service":"com.victronenergy.battery/0","name":"Lynx Shunt"},"pathObj":{"path":"/Soc","type":"float","name":"State of charge (%)"},"name":"","onlyChanges":true,"roundValues":"1","x":170,"y":240,"wires":[["3da139c390ca02f2"]],"info":"This node detects the Battery SOC"},{"id":"9e2f105c3fdd8b1a","type":"debug","z":"20c7e42d04a89526","d":true,"name":"debug 19","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":980,"y":200,"wires":[]},{"id":"757c59a609b112a6","type":"function","z":"20c7e42d04a89526","d":true,"name":"Gen / SOC Threshold","func":"// Retrieve thresholds from flow context\nconst thresholdHigh = flow.get(\"thresholdHigh\") || 81; // Default if not set\nconst thresholdLow = flow.get(\"thresholdLow\") || 70; // Default if not set\n\n// Log the incoming payload to check its structure\nnode.warn(\"Payload received: \" + JSON.stringify(msg.payload));\n\nif (!msg.payload || isNaN(parseFloat(msg.payload))) {\n node.warn(\"Invalid payload format.\");\n return null; // Exit if payload is invalid\n}\n\nconst batterySoC = parseFloat(msg.payload);\nnode.warn(\"Parsed Battery SoC: \" + batterySoC);\n\n// Determine relay state\nif (batterySoC > thresholdHigh) {\n msg.payload = 0; // OFF\n node.warn(\"Relay OFF: SoC > \" + thresholdHigh);\n} else if (batterySoC < thresholdLow) {\n msg.payload = 1; // ON\n node.warn(\"Relay ON: SoC < \" + thresholdLow);\n} else {\n node.warn(\"No relay change: SoC within thresholds\");\n return null; // No change\n}\n\nreturn msg;\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":700,"y":80,"wires":[["4038995ba39be0cb","9e2f105c3fdd8b1a"]],"info":"# SOC charge window settings\nmin-max"},{"id":"07050f3b67039393","type":"inject","z":"20c7e42d04a89526","d":true,"name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"%","payload":"76","payloadType":"num","x":150,"y":100,"wires":[["81c246ad233ab6f3"]],"info":"# Manual SOC inkject Max"},{"id":"87bdb79a1adbb94e","type":"inject","z":"20c7e42d04a89526","d":true,"name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"%","payload":"64","payloadType":"num","x":150,"y":140,"wires":[["81c246ad233ab6f3"]],"info":"# Manual SOC inkject Min"},{"id":"d24932f774729e21","type":"victron-output-vebus","z":"20c7e42d04a89526","service":"com.victronenergy.vebus/276","path":"/Mode","serviceObj":{"service":"com.victronenergy.vebus/276","name":"Multi 01"},"pathObj":{"path":"/Mode","type":"enum","name":"Switch Position","enum":{"1":"Charger Only","2":"Inverter Only","3":"On","4":"Off"},"mode":"both"},"name":"","onlyChanges":false,"x":910,"y":360,"wires":[],"info":"# Inverter Swithch Position\nStet to switch from Inverter only to Charger only and viceversa."},{"id":"39dd81ea2b77bfc2","type":"inject","z":"20c7e42d04a89526","name":"2-Inverter ONLY @ 6:58","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"58 06 * * *","once":false,"onceDelay":0.1,"topic":"2","payload":"2","payloadType":"num","x":190,"y":360,"wires":[["d24932f774729e21","484597973e272619"]],"info":"# Changes the Inverter status to \"inverter only\"\nso that the inverter output resume and the grid disconnects Soon after as the relay in the solar shed is deactivated by eWelink"},{"id":"565e0d2dcb6ceb08","type":"inject","z":"20c7e42d04a89526","name":"1-Charger Only @ 1:01","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"02 01 * * *","once":false,"onceDelay":0.1,"topic":"1","payload":"1","payloadType":"num","x":190,"y":320,"wires":[["d24932f774729e21","484597973e272619"]],"info":"# Changes the Inverter status to \"charger only\" \nso that the inverter output stops and the grid is connected and available for charging\nas long as the relay in the solar shed is activated by eWelink"},{"id":"864154c24ad5726c","type":"inject","z":"20c7e42d04a89526","name":"3-Iverter ON ","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"3","payload":"3","payloadType":"num","x":130,"y":520,"wires":[["d24932f774729e21"]]},{"id":"56cb896dd32a3a33","type":"inject","z":"20c7e42d04a89526","name":"4-Iverter OFF","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"4","payload":"4","payloadType":"num","x":150,"y":580,"wires":[["d24932f774729e21"]],"info":"# Dasboard switch inverter OFF"},{"id":"3da139c390ca02f2","type":"function","z":"20c7e42d04a89526","d":true,"name":"Store SOC","func":"flow.set(\"soc\", msg.payload);\nreturn null; // or return msg if you want to pass it downstream\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":410,"y":240,"wires":[["01d657f7469abe8f"]],"info":"# Stores the SOC"},{"id":"01d657f7469abe8f","type":"function","z":"20c7e42d04a89526","d":true,"name":"Repeat SOC","func":"let soc = flow.get(\"soc\");\nif (soc !== undefined) {\n msg.payload = soc;\n return msg;\n}\nreturn null;\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":750,"y":240,"wires":[["81c246ad233ab6f3","9e2f105c3fdd8b1a"]],"info":"# Relays the SOC every at intervals"},{"id":"81c246ad233ab6f3","type":"function","z":"20c7e42d04a89526","d":true,"name":"TIME 1:03 > 6:55","func":"let now = new Date();\nlet hour = now.getHours();\nlet minute = now.getMinutes();\n\nif (\n (hour === 1 && minute >= 03) ||\n (hour > 1 && hour < 6) ||\n (hour === 6 && minute <= 55)\n) {\n return msg; // allow during 01:05–06:58\n}\nreturn null; // block outside that window\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":450,"y":80,"wires":[["757c59a609b112a6"]],"info":"# Charge time window setting"},{"id":"36c23dc4c63dcc97","type":"inject","z":"20c7e42d04a89526","d":true,"name":"Trigger","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"15","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":580,"y":280,"wires":[["01d657f7469abe8f"]],"info":"# Inject which frequently triggers the time watchdog "},{"id":"484597973e272619","type":"debug","z":"20c7e42d04a89526","name":"debug 26","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":900,"y":480,"wires":[]}]