Firstly, most people will probably use the MQTT output from GivTCP – so this is for people that want to be different and perhaps learn a bit more about Json and Node red and automations.
Its based on someone else’s original flow – but I’ve forgotten who it was – and I’ve added a fair bit to it and updated it to the latest version of Node-Red (For Home Assistant)
I’m running Node Red as an addin to Home Assistant, but it should work as a standalone program.
I’ve not tested the charge/discharge bit!
You need to enable Json output in GivTcp Env
- JSON_OUTPUT=True # Outputs the data in JSON format
You also need to turn off self run as the flow makes the call.
- SELF_RUN=False # If True the container will self-run and connect and publish data. If "False" the you will need to trigger externally via REST
I have a few other things in my flow – I send some data out as Modbus as I use it elsewhere and also read in some modbus data as I display that on my Home Assistant dashboard – that bit can just be deleted if you don’t want to use it – but is also shows some of the formatting – may or may not be the efficient way!
You should only need to change the API info config box at the top left with your Inverter IP address and Battery Serial number. There are IP addresses in the Modbus bit, but most people will delete that bit I expect.
Copy the code below into the Node-red import dialog box.
[{"id":"2abb1f4f.a17b3","type":"tab","label":"GivTCP to HA (json)","disabled":false,"info":""},{"id":"c7caf11c.89579","type":"function","z":"2abb1f4f.a17b3","name":"Power flow stats","func":"var solarcheck=0;\nvar importcheck=0;\nvar exportcheck=0;\nvar chargecheck=0;\nvar dischargecheck=0;\nvar inverterSerial = flow.get(\"inverter_Serial\")\n\nvar pvPower = Number(msg.payload['Power']['Power']['PV_Power']);\nvar gridPower = Number(msg.payload['Power']['Power']['Grid_Power']);\nvar import_w = Number(msg.payload['Power']['Power']['Import_Power']);\nvar export_w = Number(msg.payload['Power']['Power']['Export_Power']);\nvar EPSPower= Number(msg.payload['Power']['Power']['EPS_Power']);\nvar InvertorPower= Number(msg.payload['Power']['Power']['Invertor_Power']);\nvar loadPower= Number(msg.payload['Power']['Power']['Load_Power']);\nvar batpower = Number(msg.payload['Power']['Power']['Battery_Power']);\nvar chargepower = Number(msg.payload['Power']['Power']['Charge_Power']);\nvar dischargepower = Number(msg.payload['Power']['Power']['Discharge_Power']);\nvar soc=Number(msg.payload['Power']['Power']['SOC']);\nvar battery_Capacity = Number(msg.payload['Invertor_Details']['Battery_Capacity_kWh']);\nvar soc_kwh = Number(soc*battery_Capacity);\n\nvar S2H= Number(msg.payload['Power']['Flows']['Solar_to_House'])\nvar S2B= Number(msg.payload['Power']['Flows']['Solar_to_Battery'])\nvar B2H= Number(msg.payload['Power']['Flows']['Battery_to_House'])\nvar G2B= Number(msg.payload['Power']['Flows']['Grid_to_Battery'])\nvar G2H= Number(msg.payload['Power']['Flows']['Grid_to_House'])\nvar B2G= Number(msg.payload['Power']['Flows']['Battery_to_Grid'])\nvar S2G= Number(msg.payload['Power']['Flows']['Solar_to_Grid'])\n\n////////////////// DROP old Payload ///////////////\nmsg.payload = {};\n\n//if (isNaN(parseFloat(pvPower))) pvPower = 0;\n//if (isNaN(parseFloat(loadPower))) loadPower = 0;\n//if (isNaN(parseFloat(import_w))) import_w = 0;\n//if (isNaN(parseFloat(export_w))) export_w = 0;\n//if (isNaN(parseFloat(batpower))) batpower = 0;\n//if (isNaN(parseFloat(chargepower))) chargepower = 0;\n//if (isNaN(parseFloat(dischargepower))) dischargepower = 0;\n//if (isNaN(parseFloat(soc))) soc = 0;\n//if (isNaN(parseFloat(EPSPower))) EPSPower = 0;\n//if (isNaN(parseFloat(InvertorPower))) InvertorPower = 0;\n\n\n/////////////////Re-populate payload//////////////\n\nif (isNaN(batpower)== false) msg.payload.batpower = Number(batpower);\nif (isNaN(dischargepower)== false) msg.payload.discharge = Number(dischargepower);\nif (isNaN(chargepower)== false) msg.payload.charge = Number(chargepower);\nif (isNaN(gridPower)== false) msg.payload.gridPower = Number(gridPower);\nif (isNaN(export_w)== false) msg.payload.export = Number(export_w);\nif (isNaN(import_w)== false) msg.payload.import = Number(import_w);\nif (isNaN(pvPower)== false) msg.payload.pvPower = Number(pvPower);\nif (isNaN(soc)== false) msg.payload.soc = Number(soc);\nif (isNaN(soc)== false) msg.payload.soc_kwh = Number(soc*(battery_Capacity/100)).toFixed(2);\nif (isNaN(loadPower)== false) msg.payload.loadPower = Number(loadPower);\nif (isNaN(InvertorPower)== false) msg.payload.InvertorPower = Number(InvertorPower);\nif (isNaN(EPSPower)== false) msg.payload.epsPower = Number(EPSPower);\nif (isNaN(S2H)== false) msg.payload.S2H = Number(S2H);\nif (isNaN(S2B)== false) msg.payload.S2B = Number(S2B);\nif (isNaN(B2H)== false) msg.payload.B2H = Number(B2H);\nif (isNaN(G2B)== false) msg.payload.G2B = Number(G2B);\nif (isNaN(G2H)== false) msg.payload.G2H = Number(G2H);\nif (isNaN(B2G)== false) msg.payload.B2G = Number(B2G);\nif (isNaN(S2G)== false) msg.payload.S2G = Number(S2G);\n\n/////////////////Cross check values//////////////\nsolarcheck=pvPower-S2H-S2G-S2B;\nimportcheck=import_w-G2H-G2B;\nexportcheck=export_w-S2G-B2G;\nchargecheck=chargepower-G2B-S2B;\ndischargecheck=dischargepower-B2G-B2H;\n\nvar solarcheckcalc=\"Solarcheck:\"+pvPower+\"-\"+S2H+\"-\"+S2G+\"-\"+S2B+\"=\"+solarcheck;\nvar importcheckcalc=\"importcheck:\"+import_w+\"-\"+G2H+\"-\"+G2B+\"=\"+importcheck;\nvar exportcheckcalc=\"exportcheck:\"+export_w+\"-\"+S2G+\"-\"+B2G+\"=\"+exportcheck;\nvar chargecheckcalc=\"chargecheck:\"+chargepower+\"-\"+G2B+\"-\"+S2B+\"=\"+chargecheck;\nvar dischargecheckcalc=\"dischargecheck:\"+dischargepower+\"-\"+B2G+\"-\"+B2H+\"=\"+dischargecheck;\nvar flowcheck=solarcheck+importcheck+exportcheck+chargecheck+dischargecheck;\n\nvar error=[];\nif (flowcheck==0)\n{\n error[0]=\"Flows are congruent\"\n}\nelse\n{\n error[0]=\"Flows are mismatched\"\n}\nerror[1]=flowcheck;\nerror[2]=solarcheckcalc;\nerror[3]=importcheckcalc;\nerror[4]=exportcheckcalc;\nerror[5]=chargecheckcalc;\nerror[6]=dischargecheckcalc;\n\n\n\n\nmsg.flowCheck=error;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":740,"y":240,"wires":[["4bb35161.90c58","a520e56d.e3c238","87b9af3.76b7a5","d9663d57.8bd91","a822068d.1a8258","5857cc7d.735a24","45f18568.065b1c","37251efc.182462","4f610944.963348","1bf9f1bc.53fe1e","5c60e410.e2867c","7d592604.a78d18","5c5a68688e21615b"]]},{"id":"c076003b.e2ed1","type":"debug","z":"2abb1f4f.a17b3","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1270,"y":220,"wires":[]},{"id":"6d3c2068.2a7ea","type":"api-call-service","z":"2abb1f4f.a17b3","name":"Update GivEnergy Charge Mode","server":"e9933ddd.73d49","version":5,"debugenabled":false,"domain":"input_select","service":"select_option","areaId":[],"deviceId":[],"entityId":["{{flow.ha_chargemode}}"],"data":"{\"option\":msg.payload.mode}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"data"}],"queue":"none","x":1490,"y":1260,"wires":[[]]},{"id":"235853e8.70e02c","type":"api-call-service","z":"2abb1f4f.a17b3","name":"Charge Enable set State","server":"e9933ddd.73d49","version":5,"debugenabled":false,"domain":"switch","service":"turn_{{payload}}","areaId":[],"deviceId":[],"entityId":["switch.givenergy_charge_enable"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"data"}],"queue":"none","x":1630,"y":1020,"wires":[[]]},{"id":"e1dc315f.8eef9","type":"api-call-service","z":"2abb1f4f.a17b3","name":"Discharge Enable set State","server":"e9933ddd.73d49","version":5,"debugenabled":false,"domain":"switch","service":"turn_{{payload}}","areaId":[],"deviceId":[],"entityId":["switch.givenergy_discharge_enable"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"data"}],"queue":"none","x":1640,"y":1080,"wires":[[]]},{"id":"b5a38cee.997ac","type":"api-call-service","z":"2abb1f4f.a17b3","name":"Update targetSOC","server":"e9933ddd.73d49","version":5,"debugenabled":false,"domain":"input_number","service":"set_value","areaId":[],"deviceId":[],"entityId":["{{flow.ha_targetSOC}}"],"data":"{\"value\":msg.payload.chargeUpTo}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"data"}],"queue":"none","x":1450,"y":1140,"wires":[[]]},{"id":"5c60e410.e2867c","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery SOC","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Battery SOC"},{"property":"device_class","value":"battery"},{"property":"icon","value":"mdi:battery"},{"property":"unit_of_measurement","value":"%"},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"payload.soc","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1510,"y":840,"wires":[["18e6c87c.d960a8"]]},{"id":"fff43e2c.6e5","type":"debug","z":"2abb1f4f.a17b3","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1170,"y":980,"wires":[]},{"id":"533aafe2.090da","type":"switch","z":"2abb1f4f.a17b3","name":"","property":"payload.ChargeFlag","propertyType":"msg","rules":[{"t":"neq","v":"Unknown","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1150,"y":1020,"wires":[["870b4227.1554"]]},{"id":"58657be9.ff1324","type":"function","z":"2abb1f4f.a17b3","name":"Set Control Data","func":"let forceCharge=msg.payload['raw']['invertor']['Charge_Schedule_State'];\n\nif (forceCharge ==\"Active\")\n{\n chargeMode = \"on\";\n} \nelse if (forceCharge ==\"Paused\")\n{\n chargeMode=\"off\";\n}\nelse\n{\n chargeMode=\"Unknown\";\n}\nmsg.payload.ChargeFlag=chargeMode;\n\nlet forceDischarge=msg.payload['raw']['invertor']['Discharge_Schedule_State'];\n\nif (forceDischarge ==\"Active\")\n{\n dischargeMode = \"on\";\n} \nelse if (forceDischarge ==\"Paused\")\n{\n dischargeMode=\"off\";\n}\nelse\n{\n dischargeMode=\"Unknown\";\n}\nmsg.payload.DischargeFlag=dischargeMode;\nmsg.payload.chargeUpTo=Number(msg.payload['Control']['Target_SOC']);\nmsg.payload.dischargeDownTo=Number(msg.payload['Control']['Battery_Power_Reserve']);\nvar mode=msg.payload['Control']['Mode'];\n\nswitch(mode){\n case 1:\n output=\"Mode 1 - Dynamic\";\n break;\n case 2:\n output=\"Mode 2 - Demand matched discharge\";\n break;\n case 3:\n output=\"Mode 3 - Full power discharge\";\n break;\n case 4:\n output=\"Mode 4 - Full power discharge\";\n break;\n case 5:\n output=\"Mode 5 - Octopus Smart\";\n break;\n default:\n output=\"Unknown\"\n}\nmsg.payload.mode=output\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":870,"y":1120,"wires":[["533aafe2.090da","6ddf0acd.93d7e4","b4d8fa50.4c6128","972115f0.3719d8","71647975.c7e8d8","fff43e2c.6e5"]]},{"id":"6ddf0acd.93d7e4","type":"switch","z":"2abb1f4f.a17b3","name":"","property":"payload.DischargeFlag","propertyType":"msg","rules":[{"t":"neq","v":"Unknown","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1150,"y":1080,"wires":[["74cf8a57.8ebd24"]]},{"id":"68d7fb75.7443b4","type":"api-call-service","z":"2abb1f4f.a17b3","name":"Update charge Stop 1","server":"e9933ddd.73d49","version":5,"debugenabled":false,"domain":"input_datetime","service":"set_datetime","areaId":[],"deviceId":[],"entityId":["{{flow.ha_charge_stop_time}}"],"data":"\t\t{\"time\":msg.payload.chargeSchedule1End}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"data"}],"queue":"none","x":1500,"y":1440,"wires":[[]]},{"id":"57396101.ba8fe","type":"api-call-service","z":"2abb1f4f.a17b3","name":"Update charge Start 1","server":"e9933ddd.73d49","version":5,"debugenabled":false,"domain":"input_datetime","service":"set_datetime","areaId":[],"deviceId":[],"entityId":["{{flow.ha_charge_start_time}}"],"data":"\t\t{\"time\":msg.payload.chargeSchedule1Start}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"data"}],"queue":"none","x":1500,"y":1380,"wires":[[]]},{"id":"b295651b.452ba8","type":"switch","z":"2abb1f4f.a17b3","name":"","property":"payload.chargeSchedule1End","propertyType":"msg","rules":[{"t":"neq","v":"00:-1:00","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1190,"y":1440,"wires":[["46c08530.905a8c"]]},{"id":"fc216633.1e0038","type":"switch","z":"2abb1f4f.a17b3","name":"","property":"payload.chargeSchedule1Start","propertyType":"msg","rules":[{"t":"neq","v":"00:-1:00","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1190,"y":1380,"wires":[["a04f196e.1bf378"]]},{"id":"bae76be8.ebb7d8","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery Price","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Battery Price"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:cash"},{"property":"unit_of_measurement","value":"p"},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"kwh.battprice","stateType":"flow","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2910,"y":840,"wires":[[]]},{"id":"ca193919.f415d8","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery ppkwh","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Battery ppkwh"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:cash"},{"property":"unit_of_measurement","value":"p"},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"kwh.ppkwh","stateType":"flow","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2910,"y":900,"wires":[[]]},{"id":"3fbafa9f.496546","type":"function","z":"2abb1f4f.a17b3","name":"Calculate ppkwh","func":"const globalHomeAssistant = global.get('homeassistant');\nvar time2charge=0;\n\nvar old_S2B_kwh = flow.get('kwh.old_S2B');\nvar S2B_kwh = flow.get('kwh.S2Bkwh');\n\nvar G2B_kwh = flow.get('kwh.G2Bkwh');\nvar old_G2B_kwh = flow.get('kwh.old_G2B');\n\nvar discharge = flow.get('kwh.discharge');\nvar charge = flow.get('kwh.charge');\n\nvar discharge_kwh = flow.get('kwh.dischargekwh');\nvar old_discharge_kwh = flow.get('kwh.old_discharge');\n\nvar ppkwh = parseFloat(flow.get('kwh.ppkwh'));\nvar battery_price = parseFloat(flow.get('kwh.battprice'));\nvar current_price = globalHomeAssistant.homeAssistant.states[\"sensor.octopus_agile_current_rate\"].state;\nvar SOC_kwh = flow.get('kwh.soc_kwh');\n\nif (isNaN(parseFloat(S2B_kwh))) S2B_kwh = 0;\nif (isNaN(parseFloat(old_S2B_kwh))) old_S2B_kwh = 0;\nif (isNaN(parseFloat(old_G2B_kwh))) old_G2B_kwh = 0;\nif (isNaN(parseFloat(G2B_kwh))) G2B_kwh = 0;\nif (isNaN(parseFloat(discharge_kwh))) discharge_kwh = 0;\nif (isNaN(parseFloat(old_discharge_kwh))) old_discharge_kwh = 0;\nif (isNaN(parseFloat(ppkwh))) ppkwh = 0;\nif (isNaN(parseFloat(battery_price))) battery_price = 0;\nif (isNaN(parseFloat(current_price))) current_price = 0;\nif (isNaN(parseFloat(SOC_kwh))) SOC_kwh = 0;\n\n//node.warn(\"Load= \"+load);\n\nvar S2B_Change=S2B_kwh-old_S2B_kwh;\nvar G2B_Change=G2B_kwh-old_G2B_kwh;\n\nvar discharge_change=discharge_kwh-old_discharge_kwh;\nvar G2B_pence_in=G2B_Change*current_price;\nvar pence_out=discharge_change*ppkwh;\nvar new_battery_price=battery_price+G2B_pence_in-pence_out;\nif (new_battery_price<0) new_battery_price = 0;\nif (G2B_pence_in>0) ppkwh=new_battery_price/SOC_kwh;\n\n//node.warn(\"S2B change calc: \"+S2B_kwh+\" - \"+old_S2B_kwh+\"=\"+S2B_Change);\n//node.warn(\"G2B change calc: \"+G2B_kwh+\" - \"+old_G2B_kwh+\"=\"+G2B_Change);\n//node.warn(\"Discharge change calc: \"+discharge_kwh+\" - \"+old_discharge_kwh+\"=\"+discharge_change);\n//node.warn(\"Pence in= \"+G2B_Change+\" x \"+current_price+\"=\"+G2B_pence_in);\n//node.warn(\"Pence out= \"+discharge_change+\" x \"+ppkwh+\"=\"+pence_out);\n//node.warn(\"New Batt Price: \"+battery_price+\" + \"+G2B_pence_in+\"-\"+pence_out+\"=\"+new_battery_price);\n//node.warn(\"ppkwh calc: \"+new_battery_price+\" / \"+SOC_kwh+\"=\"+ppkwh);\n\n//Calc time to full charge/discharge\nif (charge>0)\n{\n time2charge=(8-SOC_kwh)/(charge/1000);\n}\nif (discharge>0)\n{\n time2charge=SOC_kwh/(discharge/1000);\n}\n\nvar chargeEndTime= new Date(new Date().getTime() + time2charge*60*60*1000).toLocaleTimeString();\n\n//node.warn(\"Time to Charge = \"+chargeEndTime+\" (\"+time2charge+\")\");\n\nmsg={};\nflow.set(\"chargeEndTime\",chargeEndTime);\nmsg.chargeEndTime=chargeEndTime;\nflow.set(\"kwh.old_S2B\",S2B_kwh);\nmsg.old_S2B=S2B_kwh;\nflow.set(\"kwh.old_G2B\",G2B_kwh);\nmsg.old_G2B=G2B_kwh;\nflow.set(\"kwh.old_discharge\",discharge_kwh);\nmsg.old_discharge=discharge_kwh;\nflow.set(\"kwh.battprice\",(Math.round( new_battery_price * 1e2 ) / 1e2));\nmsg.battprice=(Math.round( new_battery_price * 1e2 ) / 1e2);\nflow.set(\"kwh.ppkwh\",(Math.round( ppkwh * 1e2 ) / 1e2));\nmsg.ppkwh=(Math.round( ppkwh * 1e2 ) / 1e2);\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2380,"y":900,"wires":[["bae76be8.ebb7d8","ca193919.f415d8","6ad77e7.16eff8","ae73dd2f.1a25d","8b6c2447.da4968"]]},{"id":"6ad77e7.16eff8","type":"debug","z":"2abb1f4f.a17b3","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":2850,"y":1000,"wires":[]},{"id":"ae73dd2f.1a25d","type":"persist in","z":"2abb1f4f.a17b3","name":"SOC_Calc","storageNode":"5b965f44.9c103","x":2870,"y":960,"wires":[]},{"id":"8b6c2447.da4968","type":"ha-api","z":"2abb1f4f.a17b3","name":"Set Charge end time","server":"e9933ddd.73d49","version":1,"debugenabled":false,"protocol":"http","method":"post","path":"/api/states/input_text.charge_end_time","data":"{\t \"state\": msg.chargeEndTime\t}","dataType":"jsonata","responseType":"json","outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"results"}],"x":2900,"y":800,"wires":[[]]},{"id":"18e6c87c.d960a8","type":"rbe","z":"2abb1f4f.a17b3","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload.batteryPercent","x":1910,"y":840,"wires":[["3fbafa9f.496546"]]},{"id":"ae4d7a7b.e17188","type":"api-call-service","z":"2abb1f4f.a17b3","name":"Update discharge Start 1","server":"e9933ddd.73d49","version":5,"debugenabled":false,"domain":"input_datetime","service":"set_datetime","areaId":[],"deviceId":[],"entityId":["{{flow.ha_discharge_start1_time}}"],"data":"\t\t{\"time\":msg.payload.dischargeSchedule1Start}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"data"}],"queue":"none","x":1510,"y":1500,"wires":[[]]},{"id":"70dc658d.7e3d7c","type":"api-call-service","z":"2abb1f4f.a17b3","name":"Update discharge Stop 1","server":"e9933ddd.73d49","version":5,"debugenabled":false,"domain":"input_datetime","service":"set_datetime","areaId":[],"deviceId":[],"entityId":["{{flow.ha_discharge_stop1_time}}"],"data":"\t\t{\"time\":msg.payload.dischargeSchedule1End}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"data"}],"queue":"none","x":1510,"y":1560,"wires":[[]]},{"id":"1116879f.fed7e8","type":"switch","z":"2abb1f4f.a17b3","name":"","property":"payload.dischargeSchedule1Start","propertyType":"msg","rules":[{"t":"neq","v":"00:-1:00","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1190,"y":1500,"wires":[["d93a567f.923878"]]},{"id":"dfd3457c.535bc8","type":"switch","z":"2abb1f4f.a17b3","name":"","property":"payload.dischargeSchedule1End","propertyType":"msg","rules":[{"t":"neq","v":"00:-1:00","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1190,"y":1560,"wires":[["b285445b.4d2c38"]]},{"id":"d85d002d.58ee3","type":"api-call-service","z":"2abb1f4f.a17b3","name":"Update Battery Reserve","server":"e9933ddd.73d49","version":5,"debugenabled":false,"domain":"input_number","service":"set_value","areaId":[],"deviceId":[],"entityId":["{{flow.ha_dischargeTarget}}"],"data":"{\"value\":msg.payload.dischargeDownTo}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"data"}],"queue":"none","x":1470,"y":1200,"wires":[[]]},{"id":"5962bcbe.809174","type":"function","z":"2abb1f4f.a17b3","name":"Convert times to real times","func":"\n\nmsg.payload.dischargeSchedule1Start=msg.payload['Timeslots']['Discharge_start_time_slot_1'];\nmsg.payload.dischargeSchedule1End=msg.payload['Timeslots']['Discharge_end_time_slot_1'];\nmsg.payload.dischargeSchedule2Start=msg.payload['Timeslots']['Discharge_start_time_slot_2'];\nmsg.payload.dischargeSchedule2End=msg.payload['Timeslots']['Discharge_end_time_slot_2'];\nmsg.payload.chargeSchedule1Start=msg.payload['Timeslots']['Charge_start_time_slot_1'];\nmsg.payload.chargeSchedule1End=msg.payload['Timeslots']['Charge_end_time_slot_1'];\n\nreturn msg;\n\n\n//msg.payload.dischargeSchedule1Start=msg.payload['Timeslots']['Discharge start time slot 1'].substring(0,2)+\":\"+msg.payload['Timeslots']['Discharge start time slot 1'].substring(2)+\":00\";\n//msg.payload.dischargeSchedule1End=msg.payload['Timeslots']['Discharge end time slot 1'].substring(0,2)+\":\"+msg.payload['Timeslots']['Discharge end time slot 1'].substring(2)+\":00\";\n//msg.payload.dischargeSchedule2Start=msg.payload['Timeslots']['Discharge start time slot 2'].substring(0,2)+\":\"+msg.payload['Timeslots']['Discharge start time slot 2'].substring(2)+\":00\";\n//msg.payload.dischargeSchedule2End=msg.payload['Timeslots']['Discharge end time slot 2'].substring(0,2)+\":\"+msg.payload['Timeslots']['Discharge end time slot 2'].substring(2)+\":00\";\n//msg.payload.chargeSchedule1Start=msg.payload['Timeslots']['Charge start time slot 1'].substring(0,2)+\":\"+msg.payload['Timeslots']['Charge start time slot 1'].substring(2)+\":00\";\n//msg.payload.chargeSchedule1End=msg.payload['Timeslots']['Charge end time slot 1'].substring(0,2)+\":\"+msg.payload['Timeslots']['Charge end time slot 1'].substring(2)+\":00\";","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":940,"y":1540,"wires":[["dfd3457c.535bc8","f38dd44e.f0ab98","a27a343d.63cda8","1116879f.fed7e8","b295651b.452ba8","fc216633.1e0038","90d4d7df.00d5c8"]]},{"id":"3c86d5fa.324caa","type":"api-call-service","z":"2abb1f4f.a17b3","name":"Update discharge Start 2","server":"e9933ddd.73d49","version":5,"debugenabled":false,"domain":"input_datetime","service":"set_datetime","areaId":[],"deviceId":[],"entityId":["{{flow.ha_discharge_start2_time}}"],"data":"{\"time\":msg.payload.dischargeSchedule2Start}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"data"}],"queue":"none","x":1510,"y":1620,"wires":[[]]},{"id":"ada347da.e92dd8","type":"api-call-service","z":"2abb1f4f.a17b3","name":"Update discharge Stop 2","server":"e9933ddd.73d49","version":5,"debugenabled":false,"domain":"input_datetime","service":"set_datetime","areaId":[],"deviceId":[],"entityId":["{{flow.ha_discharge_stop2_time}}"],"data":"\t\t{\"time\":msg.payload.dischargeSchedule2End}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"data"}],"queue":"none","x":1510,"y":1680,"wires":[[]]},{"id":"a27a343d.63cda8","type":"switch","z":"2abb1f4f.a17b3","name":"","property":"payload.dischargeSchedule2End","propertyType":"msg","rules":[{"t":"neq","v":"00:-1:00","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1190,"y":1620,"wires":[["c48e9b5e.9eea78"]]},{"id":"f38dd44e.f0ab98","type":"switch","z":"2abb1f4f.a17b3","name":"","property":"payload.dischargeSchedule2End","propertyType":"msg","rules":[{"t":"neq","v":"00:-1:00","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1190,"y":1680,"wires":[["f6a69f01.644fc"]]},{"id":"45f18568.065b1c","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Import","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Import"},{"property":"device_class","value":"power"},{"property":"icon","value":"mdi:transmission-tower"},{"property":"unit_of_measurement","value":"W"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.import","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1490,"y":660,"wires":[["93025cc820aa7c6d"]]},{"id":"37251efc.182462","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Export","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Export"},{"property":"device_class","value":"power"},{"property":"icon","value":"mdi:transmission-tower"},{"property":"unit_of_measurement","value":"W"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.export","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1490,"y":720,"wires":[["b0e5e659ebefa976"]]},{"id":"d9663d57.8bd91","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Charge power","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Charge power"},{"property":"device_class","value":"power"},{"property":"icon","value":"mdi:battery-charging"},{"property":"unit_of_measurement","value":"W"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.charge","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1510,"y":480,"wires":[["6e9f47f246583e6c"]]},{"id":"a822068d.1a8258","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Discharge power","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy discharge power"},{"property":"device_class","value":"power"},{"property":"icon","value":"mdi:battery-charging"},{"property":"unit_of_measurement","value":"W"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.discharge","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1520,"y":540,"wires":[["b752e89e7d096e50"]]},{"id":"87b9af3.76b7a5","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery Power","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Battery Power"},{"property":"device_class","value":"power"},{"property":"icon","value":"mdi:battery-charging"},{"property":"unit_of_measurement","value":"W"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.batpower","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1510,"y":420,"wires":[["d7675146e294c45c"]]},{"id":"5857cc7d.735a24","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Grid Power","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Grid Power"},{"property":"device_class","value":"power"},{"property":"icon","value":"mdi:transmission-tower"},{"property":"unit_of_measurement","value":"W"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.gridPower","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1500,"y":600,"wires":[["3d6451c3d2bdbadd"]]},{"id":"4bb35161.90c58","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Load Power","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Load Power"},{"property":"device_class","value":"power"},{"property":"icon","value":"mdi:home-lightbulb"},{"property":"unit_of_measurement","value":"W"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.loadPower","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1510,"y":300,"wires":[["724dd792789e202d"]],"outputLabels":["Output"]},{"id":"a520e56d.e3c238","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Solar Power","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Solar Power"},{"property":"device_class","value":"power"},{"property":"icon","value":"mdi:solar-power"},{"property":"unit_of_measurement","value":"W"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.pvPower","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1510,"y":360,"wires":[["08d294e28a4fbca1"]]},{"id":"4f610944.963348","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy EPS","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy EPS"},{"property":"device_class","value":"power"},{"property":"icon","value":"mdi:transmission-tower"},{"property":"unit_of_measurement","value":"W"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.epsPower","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1480,"y":780,"wires":[[]]},{"id":"1bf9f1bc.53fe1e","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery SOC kWh","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Battery SOC kWh"},{"property":"device_class","value":"energy"},{"property":"icon","value":"mdi:battery"},{"property":"unit_of_measurement","value":"kWh"},{"property":"state_class","value":"total"},{"property":"last_reset","value":""}],"state":"payload.soc_kwh","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1520,"y":900,"wires":[[]]},{"id":"da9539f3.b3d2c8","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Solar to House","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Solar to House"},{"property":"device_class","value":"power"},{"property":"icon","value":"mdi:solar-power"},{"property":"unit_of_measurement","value":"W"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.S2H","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2910,"y":360,"wires":[["20727ffc.392d2"]]},{"id":"c38a7edd.8bcd1","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Solar to Battery","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Solar to Battery"},{"property":"device_class","value":"power"},{"property":"icon","value":"mdi:solar-power"},{"property":"unit_of_measurement","value":"W"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.S2B","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2920,"y":420,"wires":[["abf5c774.a06c78"]]},{"id":"ebb23fe5.6f36a","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery to House","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Battery to House"},{"property":"device_class","value":"power"},{"property":"icon","value":"mdi:battery-charging"},{"property":"unit_of_measurement","value":"W"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.B2H","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2920,"y":480,"wires":[["f62922fb.67961"]]},{"id":"5e158aec.fdaa54","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Grid to House","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Grid to House"},{"property":"device_class","value":"power"},{"property":"icon","value":"mdi:transmission-tower"},{"property":"unit_of_measurement","value":"W"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.G2H","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2910,"y":540,"wires":[["1ebb5687.b08059"]]},{"id":"908b864a.c84778","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Grid to Battery","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Grid to Battery"},{"property":"device_class","value":"power"},{"property":"icon","value":"mdi:battery-charging"},{"property":"unit_of_measurement","value":"kW"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.G2B","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2910,"y":600,"wires":[["dd54a46b.aff408"]]},{"id":"d4ed1e35.11fed","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery to Grid","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Battery to Grid"},{"property":"device_class","value":"power"},{"property":"icon","value":"mdi:battery-charging"},{"property":"unit_of_measurement","value":"W"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.B2G","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2910,"y":660,"wires":[["6921b556.332b3c"]]},{"id":"bf205bf6.cea2b8","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Solar to Grid","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Solar to Grid"},{"property":"device_class","value":"power"},{"property":"icon","value":"mdi:solar-power"},{"property":"unit_of_measurement","value":"W"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.S2G","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2910,"y":720,"wires":[["a1b7f82b.e3ae68"]]},{"id":"973a1542.5712c8","type":"watt2kwh","z":"2abb1f4f.a17b3","format":"kwh","maximum":"5","maximumunit":"mins","name":"","x":3420,"y":260,"wires":[["cc27693c.a6d888"]]},{"id":"cc27693c.a6d888","type":"function","z":"2abb1f4f.a17b3","name":"Store kwh","func":"//if (isNaN(parseFloat(msg.payload))) msg.payload = 0;\n\nvar inputVal = msg.payload;\nvar savedVal = parseFloat(flow.get(\"kwh.S2Hkwh\"));\nif (isNaN(savedVal)) savedVal = 0;\nif (inputVal == \"reset\")\n{\n savedVal=0; \n} \nelse \n{\n//node.warn(\"Sum= \"+savedVal+\"+\"+inputVal);\nsavedVal += inputVal;\n}\nmsg = {};\nmsg.S2Hkwh=parseFloat(savedVal).toFixed(4);\nflow.set(\"kwh.S2Hkwh\",msg.S2Hkwh);\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3580,"y":240,"wires":[["7332a6ac.00e068","b3a295b2e80a4366"]]},{"id":"eaafd563.7a5968","type":"inject","z":"2abb1f4f.a17b3","name":"reset","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"00 00 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"reset","payloadType":"str","x":3430,"y":220,"wires":[["cc27693c.a6d888"]]},{"id":"7332a6ac.00e068","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Solar to House kWh","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Solar to House kWh"},{"property":"device_class","value":"energy"},{"property":"icon","value":"mdi:solar-power"},{"property":"unit_of_measurement","value":"kWh"},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"S2Hkwh","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":3800,"y":240,"wires":[[]]},{"id":"a2af2076.c18fb","type":"watt2kwh","z":"2abb1f4f.a17b3","format":"kwh","maximum":"5","maximumunit":"mins","name":"","x":3420,"y":340,"wires":[["67b2ae03.7331b"]]},{"id":"67b2ae03.7331b","type":"function","z":"2abb1f4f.a17b3","name":"Store kwh","func":"//if (isNaN(parseFloat(msg.payload))) msg.payload = 0;\n\nvar inputVal = msg.payload;\nvar savedVal = parseFloat(flow.get(\"kwh.S2Bkwh\"));\nif (isNaN(savedVal)) savedVal = 0;\nif (inputVal == \"reset\")\n{\n savedVal=0; \n} \nelse \n{\n//node.warn(\"Sum= \"+savedVal+\"+\"+inputVal);\nsavedVal += inputVal;\n}\n//node.warn(\"Total= \"+savedVal);\nmsg = {};\nmsg.S2Bkwh=parseFloat(savedVal).toFixed(4);\nflow.set(\"kwh.S2Bkwh\",msg.S2Bkwh);\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3580,"y":320,"wires":[["1818433d.d13b9d"]]},{"id":"e1de07c6.247508","type":"inject","z":"2abb1f4f.a17b3","name":"reset","repeat":"","crontab":"00 00 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"reset","payloadType":"str","x":3430,"y":300,"wires":[["67b2ae03.7331b"]]},{"id":"1818433d.d13b9d","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Solar to Battery kWh","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Solar to Battery kWh"},{"property":"device_class","value":"energy"},{"property":"icon","value":"mdi:battery-charging"},{"property":"unit_of_measurement","value":"kWh"},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"S2Bkwh","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":3800,"y":320,"wires":[[]]},{"id":"77237fe.60ad88","type":"watt2kwh","z":"2abb1f4f.a17b3","format":"kwh","maximum":"5","maximumunit":"mins","name":"","x":3420,"y":420,"wires":[["7c5686c6.fda4d8"]]},{"id":"7c5686c6.fda4d8","type":"function","z":"2abb1f4f.a17b3","name":"Store kwh","func":"//if (isNaN(parseFloat(msg.payload))) msg.payload = 0;\n\nvar inputVal = msg.payload;\nvar savedVal = parseFloat(flow.get(\"kwh.B2Hkwh\"));\nif (isNaN(savedVal)) savedVal = 0;\nif (inputVal == \"reset\")\n{\n savedVal=0; \n} \nelse \n{\n//node.warn(\"Sum= \"+savedVal+\"+\"+inputVal);\nsavedVal += inputVal;\n}\nmsg = {};\nmsg.B2Hkwh=parseFloat(savedVal).toFixed(4);\nflow.set(\"kwh.B2Hkwh\",msg.B2Hkwh);\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3580,"y":400,"wires":[["3c2aa9da.035ed6"]]},{"id":"ace383af.e13ab","type":"inject","z":"2abb1f4f.a17b3","name":"reset","repeat":"","crontab":"00 00 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"reset","payloadType":"str","x":3430,"y":380,"wires":[["7c5686c6.fda4d8"]]},{"id":"3c2aa9da.035ed6","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery to House kWh","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Battery to House kWh"},{"property":"device_class","value":"energy"},{"property":"icon","value":"mdi:battery-charging"},{"property":"unit_of_measurement","value":"kWh"},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"B2Hkwh","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":3810,"y":400,"wires":[[]]},{"id":"4edcfbbc.dc5644","type":"watt2kwh","z":"2abb1f4f.a17b3","format":"kwh","maximum":"5","maximumunit":"mins","name":"","x":3420,"y":500,"wires":[["4d0c2a80.a776b4"]]},{"id":"4d0c2a80.a776b4","type":"function","z":"2abb1f4f.a17b3","name":"Store kwh","func":"//if (isNaN(parseFloat(msg.payload))) msg.payload = 0;\nif (isNaN(parseFloat(msg.currentkwh))) msg.currentkwh = 0;\n\nvar inputVal = msg.payload;\nvar savedVal = parseFloat(flow.get(\"kwh.G2Hkwh\"));\nif (isNaN(savedVal)) savedVal = 0;\nif (inputVal == \"reset\")\n{\n savedVal=0; \n} \nelse \n{\n//node.warn(\"Sum= \"+savedVal+\"+\"+inputVal);\nsavedVal += inputVal;\n}\nmsg = {};\nmsg.G2Hkwh=parseFloat(savedVal).toFixed(4);\nflow.set(\"kwh.G2Hkwh\",msg.G2Hkwh);\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3580,"y":480,"wires":[["c0915a86.3b5368"]]},{"id":"cf60c399.90c68","type":"inject","z":"2abb1f4f.a17b3","name":"reset","props":[{"p":"payload","v":"reset","vt":"str"},{"p":"topic","v":"","vt":"str"}],"repeat":"","crontab":"00 00 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"reset","payloadType":"str","x":3430,"y":460,"wires":[["4d0c2a80.a776b4"]]},{"id":"c0915a86.3b5368","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Grid to House kWh","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Grid to House kWh"},{"property":"device_class","value":"energy"},{"property":"icon","value":"mdi:battery-charging"},{"property":"unit_of_measurement","value":"kWh"},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"G2Hkwh","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":3800,"y":480,"wires":[[]]},{"id":"a032615f.e7ccb","type":"watt2kwh","z":"2abb1f4f.a17b3","format":"kwh","maximum":"5","maximumunit":"mins","name":"","x":3420,"y":580,"wires":[["2c81a299.18d0ce"]]},{"id":"2c81a299.18d0ce","type":"function","z":"2abb1f4f.a17b3","name":"Store kwh","func":"//if (isNaN(parseFloat(msg.payload))) msg.payload = 0;\nif (isNaN(parseFloat(msg.currentkwh))) msg.currentkwh = 0;\n\nvar inputVal = msg.payload;\nvar savedVal = parseFloat(flow.get(\"kwh.G2Bkwh\"));\nif (isNaN(savedVal)) savedVal = 0;\nif (inputVal == \"reset\")\n{\n savedVal=0; \n} \nelse \n{\n//node.warn(\"Sum= \"+savedVal+\"+\"+inputVal);\nsavedVal += inputVal;\n}\nmsg = {};\nmsg.G2Bkwh=parseFloat(savedVal).toFixed(4);\nflow.set(\"kwh.G2Bkwh\",msg.G2Bkwh);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3580,"y":560,"wires":[["4a10e1ea.df2cf"]]},{"id":"9385823e.d889d","type":"inject","z":"2abb1f4f.a17b3","name":"reset","repeat":"","crontab":"00 00 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"reset","payloadType":"str","x":3430,"y":540,"wires":[["2c81a299.18d0ce"]]},{"id":"4a10e1ea.df2cf","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Grid to Battery kWh","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Grid to Battery kWh"},{"property":"device_class","value":"energy"},{"property":"icon","value":"mdi:battery-charging"},{"property":"unit_of_measurement","value":"kWh"},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"G2Bkwh","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":3800,"y":560,"wires":[[]]},{"id":"690c0961.c900c8","type":"watt2kwh","z":"2abb1f4f.a17b3","format":"kwh","maximum":"5","maximumunit":"mins","name":"","x":3420,"y":660,"wires":[["9ddf277d.e9dd98"]]},{"id":"9ddf277d.e9dd98","type":"function","z":"2abb1f4f.a17b3","name":"Store kwh","func":"//if (isNaN(parseFloat(msg.payload))) msg.payload = 0;\n\nvar inputVal = msg.payload;\nvar savedVal = parseFloat(flow.get(\"kwh.B2Gkwh\"));\nif (isNaN(savedVal)) savedVal = 0;\nif (inputVal == \"reset\")\n{\n savedVal=0; \n} \nelse \n{\n//node.warn(\"Sum= \"+savedVal+\"+\"+inputVal);\nsavedVal += inputVal;\n}\nmsg = {};\nmsg.B2Gkwh=parseFloat(savedVal).toFixed(4);\nflow.set(\"kwh.B2Gkwh\",msg.B2Gkwh);\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3580,"y":640,"wires":[["ee703726.f53558"]]},{"id":"e0defc28.3a71f","type":"inject","z":"2abb1f4f.a17b3","name":"reset","repeat":"","crontab":"00 00 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"reset","payloadType":"str","x":3430,"y":620,"wires":[["9ddf277d.e9dd98"]]},{"id":"ee703726.f53558","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery to Grid kWh","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Battery to Grid kWh"},{"property":"device_class","value":"energy"},{"property":"icon","value":"mdi:battery-charging"},{"property":"unit_of_measurement","value":"kWh"},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"B2Gkwh","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":3800,"y":640,"wires":[[]]},{"id":"557c28b8.504d78","type":"watt2kwh","z":"2abb1f4f.a17b3","format":"kwh","maximum":"5","maximumunit":"mins","name":"","x":3420,"y":740,"wires":[["79687185.4efe9"]]},{"id":"79687185.4efe9","type":"function","z":"2abb1f4f.a17b3","name":"Store kwh","func":"//if (isNaN(parseFloat(msg.payload))) msg.payload = 0;\n\nvar inputVal = msg.payload;\nvar savedVal = (flow.get(\"kwh.S2Gkwh\"));\nif (isNaN(savedVal)) savedVal = 0;\nif (inputVal == \"reset\")\n{\n savedVal=0; \n} \nelse \n{\n//node.warn(\"Sum= \"+savedVal+\"+\"+inputVal);\nsavedVal += inputVal;\n}\nmsg = {};\nmsg.S2Gkwh=parseFloat(savedVal).toFixed(4);\nflow.set(\"kwh.S2Gkwh\",msg.S2Gkwh);\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3580,"y":720,"wires":[["31a1814a.3c2a6e"]]},{"id":"ec7f5f80.e9a1e","type":"inject","z":"2abb1f4f.a17b3","name":"reset","repeat":"","crontab":"00 00 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"reset","payloadType":"str","x":3430,"y":700,"wires":[["79687185.4efe9"]]},{"id":"31a1814a.3c2a6e","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Solar to Grid kWh","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Solar to Grid kWh"},{"property":"device_class","value":"energy"},{"property":"icon","value":"mdi:battery-charging"},{"property":"unit_of_measurement","value":"kWh"},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"S2Gkwh","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":3790,"y":720,"wires":[[]]},{"id":"20727ffc.392d2","type":"function","z":"2abb1f4f.a17b3","name":"Make a number","func":"if (isNaN(parseFloat(msg.payload.state))) msg.payload.state = 0;\nmsg.payload = parseFloat(msg.payload.state).toFixed(0);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3240,"y":260,"wires":[["973a1542.5712c8"]]},{"id":"abf5c774.a06c78","type":"function","z":"2abb1f4f.a17b3","name":"Make a number","func":"if (isNaN(parseFloat(msg.payload.state))) msg.payload.state = 0;\nmsg.payload = parseFloat(msg.payload.state).toFixed(0);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3240,"y":340,"wires":[["a2af2076.c18fb"]]},{"id":"f62922fb.67961","type":"function","z":"2abb1f4f.a17b3","name":"Make a number","func":"if (isNaN(parseFloat(msg.payload.state))) msg.payload.state = 0;\nmsg.payload = parseFloat(msg.payload.state).toFixed(0);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3240,"y":420,"wires":[["77237fe.60ad88"]]},{"id":"1ebb5687.b08059","type":"function","z":"2abb1f4f.a17b3","name":"Make a number","func":"if (isNaN(parseFloat(msg.payload.state))) msg.payload.state = 0;\nmsg.payload = parseFloat(msg.payload.state).toFixed(0);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3240,"y":500,"wires":[["4edcfbbc.dc5644"]]},{"id":"dd54a46b.aff408","type":"function","z":"2abb1f4f.a17b3","name":"Make a number","func":"if (isNaN(parseFloat(msg.payload.state))) msg.payload.state = 0;\nmsg.payload = parseFloat(msg.payload.state).toFixed(0);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3240,"y":580,"wires":[["a032615f.e7ccb"]]},{"id":"6921b556.332b3c","type":"function","z":"2abb1f4f.a17b3","name":"Make a number","func":"if (isNaN(parseFloat(msg.payload.state))) msg.payload.state = 0;\nmsg.payload = parseFloat(msg.payload.state).toFixed(0);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3240,"y":660,"wires":[["690c0961.c900c8"]]},{"id":"a1b7f82b.e3ae68","type":"function","z":"2abb1f4f.a17b3","name":"Make a number","func":"if (isNaN(parseFloat(msg.payload.state))) msg.payload.state = 0;\nmsg.payload = parseFloat(msg.payload.state).toFixed(0);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3240,"y":740,"wires":[["557c28b8.504d78"]]},{"id":"90d4d7df.00d5c8","type":"debug","z":"2abb1f4f.a17b3","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":950,"y":1440,"wires":[]},{"id":"fc09108a.687c","type":"config","z":"2abb1f4f.a17b3","name":"GivEnergy API info","properties":[{"p":"ha_discharge_start1_time","pt":"flow","to":"input_datetime.discharge_start_time_1","tot":"str"},{"p":"ha_discharge_stop1_time","pt":"flow","to":"input_datetime.discharge_stop_time_1","tot":"str"},{"p":"ha_discharge_start2_time","pt":"flow","to":"input_datetime.discharge_start_time_2","tot":"str"},{"p":"ha_discharge_stop2_time","pt":"flow","to":"input_datetime.discharge_stop_time_2","tot":"str"},{"p":"ha_charge_start_time","pt":"flow","to":"input_datetime.charge_start_time","tot":"str"},{"p":"ha_charge_stop_time","pt":"flow","to":"input_datetime.charge_stop_time","tot":"str"},{"p":"ha_targetSOC","pt":"flow","to":"input_number.smart_charge_target","tot":"str"},{"p":"ha_chargemode","pt":"flow","to":"input_select.givenergy_mode","tot":"str"},{"p":"charge_end_time","pt":"flow","to":"input_text.charge_end_time","tot":"str"},{"p":"ha_dischargeTarget","pt":"flow","to":"input_number.discharge_target","tot":"str"},{"p":"giv_tcp_base_url","pt":"flow","to":"http://192.168.1.107:6345","tot":"str"},{"p":"battery_Serial","pt":"flow","to":"BG2136G121","tot":"str"},{"p":"inverter_Serial","pt":"flow","to":"SA2142G221","tot":"str"}],"active":true,"x":110,"y":40,"wires":[]},{"id":"18d0fa3f.ec4646","type":"comment","z":"2abb1f4f.a17b3","name":"Save apiKey and get BatteryData","info":"","x":1490,"y":140,"wires":[]},{"id":"fada724d.fe063","type":"persist out","z":"2abb1f4f.a17b3","name":"SOC_Calc","storageNode":"5b965f44.9c103","x":1550,"y":180,"wires":[["bf00deba.554f","c9e98f18.9c18c","d8d04f7.bb4f1b","c46d191.3829be8","f8cb39f2.090da8","2ffa67b7.bff0e8"]]},{"id":"bf00deba.554f","type":"debug","z":"2abb1f4f.a17b3","name":"","active":true,"tosidebar":true,"console":true,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":2230,"y":40,"wires":[]},{"id":"c9e98f18.9c18c","type":"change","z":"2abb1f4f.a17b3","name":"","rules":[{"t":"set","p":"kwh.old_S2B","pt":"flow","to":"old_S2B","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2280,"y":80,"wires":[[]]},{"id":"d8d04f7.bb4f1b","type":"change","z":"2abb1f4f.a17b3","name":"","rules":[{"t":"set","p":"kwh.old_G2B","pt":"flow","to":"old_G2B","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2280,"y":120,"wires":[[]]},{"id":"c46d191.3829be8","type":"change","z":"2abb1f4f.a17b3","name":"","rules":[{"t":"set","p":"kwh.old_discharge","pt":"flow","to":"old_discharge","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2300,"y":160,"wires":[[]]},{"id":"f8cb39f2.090da8","type":"change","z":"2abb1f4f.a17b3","name":"","rules":[{"t":"set","p":"kwh.battprice","pt":"flow","to":"battprice","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2280,"y":200,"wires":[[]]},{"id":"2ffa67b7.bff0e8","type":"change","z":"2abb1f4f.a17b3","name":"","rules":[{"t":"set","p":"kwh.ppkwh","pt":"flow","to":"ppkwh","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2270,"y":240,"wires":[[]]},{"id":"59c1151e.86807c","type":"inject","z":"2abb1f4f.a17b3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1360,"y":180,"wires":[["fada724d.fe063"]]},{"id":"7d592604.a78d18","type":"debug","z":"2abb1f4f.a17b3","name":"Power Flow Stats","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1030,"y":660,"wires":[]},{"id":"1c94a5e7.01b17a","type":"function","z":"2abb1f4f.a17b3","name":"","func":"var powerStats = msg.payload['Power']['Power']\nvar powerFlowStats = msg.payload['Power']['Flows']\nvar energyTodayStats = msg.payload['Energy']['Today']\nvar energyTotalStats = msg.payload['Energy']['Total']\n\nmsg={}\nfor (const [key, value] of Object.entries(powerStats)) {\n msg.measurement=key.replace(/ /g, \"_\")\n msg.payload=value\n node.send(msg);\n}\nfor (const [key, value] of Object.entries(powerFlowStats)) {\n msg.measurement=key.replace(/ /g, \"_\")\n msg.payload=value\n node.send(msg);\n}\nfor (const [key, value] of Object.entries(energyTodayStats)) {\n msg.measurement=key.replace(/ /g, \"_\")\n msg.payload=value\n node.send(msg);\n}\nfor (const [key, value] of Object.entries(energyTotalStats)) {\n msg.measurement=key.replace(/ /g, \"_\")\n msg.payload=value\n node.send(msg);\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":880,"y":1760,"wires":[["dc90377a.de78b8","c59c6aa8.00a6a8"]]},{"id":"dc90377a.de78b8","type":"influxdb out","z":"2abb1f4f.a17b3","influxdb":"f881843250fc6031","name":"InfluxDB","measurement":"","precision":"","retentionPolicy":"","database":"homeassistant","precisionV18FluxV20":"ms","retentionPolicyV18Flux":"","org":"organisation","bucket":"bucket","x":1040,"y":1760,"wires":[]},{"id":"a9cc1150.1ae6b","type":"template","z":"2abb1f4f.a17b3","name":"Control Mode template","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\"mode\":{{mode}}}","output":"str","x":1420,"y":2320,"wires":[["427f7094.5e15b","be93c972.d3a2e8"]]},{"id":"d04bfc39.c7b44","type":"template","z":"2abb1f4f.a17b3","name":"Charge Slot 1 template","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\"start\":\"{{start}}\",\"finish\":\"{{finish}}\",\"chargeToPercent\":\"{{target}}\"}","output":"str","x":1420,"y":2820,"wires":[["427f7094.5e15b"]]},{"id":"d63c6495.068fa8","type":"template","z":"2abb1f4f.a17b3","name":"Discharge Slot template","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\"start\":\"{{start}}\",\"finish\":\"{{finish}}\",\"dischargeToPercent\":\"{{target}}\"}","output":"str","x":1430,"y":2700,"wires":[["427f7094.5e15b"]]},{"id":"9ac0dcfd.10bf7","type":"function","z":"2abb1f4f.a17b3","name":"","func":"msg.function=\"pauseChargeSchedule\";\nmsg.payload={}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1220,"y":2400,"wires":[["427f7094.5e15b"]]},{"id":"be93c972.d3a2e8","type":"debug","z":"2abb1f4f.a17b3","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":2070,"y":2580,"wires":[]},{"id":"f665c8a.b016238","type":"server-events","z":"2abb1f4f.a17b3","name":"","server":"e9933ddd.73d49","version":1,"event_type":"state_changed","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"waitForRunning":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"$outputData(\"eventData\").event_type","valueType":"jsonata"},{"property":"event_type","propertyType":"msg","value":"$outputData(\"eventData\").event_type","valueType":"jsonata"}],"x":840,"y":2520,"wires":[["76796725.d6d8a8"]]},{"id":"76796725.d6d8a8","type":"switch","z":"2abb1f4f.a17b3","name":"Check if SOC entity","property":"payload.entity_id","propertyType":"msg","rules":[{"t":"eq","v":"ha_targetSOC","vt":"flow"}],"checkall":"true","repair":false,"outputs":1,"x":1050,"y":2520,"wires":[["fd3b6093.c4c3d"]]},{"id":"8b11e32c.e8a21","type":"comment","z":"2abb1f4f.a17b3","name":"Change Target SOC from HA","info":"","x":580,"y":2520,"wires":[]},{"id":"fd3b6093.c4c3d","type":"function","z":"2abb1f4f.a17b3","name":"","func":"msg.function=\"setChargeTarget\";\nmsg.chargeToPercent=Number(msg.payload.event.new_state.state).toFixed()\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1220,"y":2520,"wires":[["4293be6d.3e6b"]]},{"id":"4293be6d.3e6b","type":"template","z":"2abb1f4f.a17b3","name":"Charge Target template","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\"chargeToPercent\":\"{{chargeToPercent}}\"}","output":"str","x":1430,"y":2520,"wires":[["427f7094.5e15b"]]},{"id":"edf9fc6a.bbdc7","type":"server-events","z":"2abb1f4f.a17b3","name":"","server":"e9933ddd.73d49","version":1,"event_type":"state_changed","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"waitForRunning":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"$outputData(\"eventData\").event_type","valueType":"jsonata"},{"property":"event_type","propertyType":"msg","value":"$outputData(\"eventData\").event_type","valueType":"jsonata"}],"x":840,"y":2320,"wires":[["54bd0678.512118"]]},{"id":"54bd0678.512118","type":"switch","z":"2abb1f4f.a17b3","name":"chargemode","property":"payload.entity_id","propertyType":"msg","rules":[{"t":"eq","v":"ha_chargemode","vt":"flow"}],"checkall":"true","repair":false,"outputs":1,"x":1030,"y":2320,"wires":[["95e43621.4e50b8"]]},{"id":"d12b68d1.0e7188","type":"comment","z":"2abb1f4f.a17b3","name":"Change Control Mode from HA","info":"","x":570,"y":2320,"wires":[]},{"id":"95e43621.4e50b8","type":"function","z":"2abb1f4f.a17b3","name":"","func":"msg.function=\"setBatteryMode\";\nvar modestring=msg.payload.event.new_state.state\nmsg.mode=modestring.match(/\\d+/)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1220,"y":2320,"wires":[["a9cc1150.1ae6b"]]},{"id":"f55ffe72.b2edb","type":"api-current-state","z":"2abb1f4f.a17b3","name":"","server":"e9933ddd.73d49","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"{{flow.ha_discharge_start1_time}}","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"start","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":800,"y":2620,"wires":[["a5395371.d84fb"]]},{"id":"a5395371.d84fb","type":"api-current-state","z":"2abb1f4f.a17b3","name":"","server":"e9933ddd.73d49","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"{{flow.ha_discharge_stop1_time}}","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"finish","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":480,"y":2660,"wires":[["4e9a4ef1.454de"]]},{"id":"ff640b5e.05b878","type":"api-current-state","z":"2abb1f4f.a17b3","name":"","server":"e9933ddd.73d49","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"{{flow.ha_charge_start_time}}","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"start","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":790,"y":2780,"wires":[["d2d9b111.36aea"]]},{"id":"d2d9b111.36aea","type":"api-current-state","z":"2abb1f4f.a17b3","name":"","server":"e9933ddd.73d49","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"{{flow.ha_charge_stop_time}}","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"finish","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":470,"y":2820,"wires":[["f7e979b4.b1c0a8"]]},{"id":"f7e979b4.b1c0a8","type":"api-current-state","z":"2abb1f4f.a17b3","name":"","server":"e9933ddd.73d49","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"{{flow.ha_targetSOC}}","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"chargeToPercent","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":850,"y":2820,"wires":[["caafad6.849d65"]]},{"id":"4e9a4ef1.454de","type":"api-current-state","z":"2abb1f4f.a17b3","name":"","server":"e9933ddd.73d49","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"{{flow.ha_dischargeTarget}}","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"dischargeToPercent","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":840,"y":2660,"wires":[["648c0c89.1b6d84"]]},{"id":"1650c494.e2ef7b","type":"api-current-state","z":"2abb1f4f.a17b3","name":"","server":"e9933ddd.73d49","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"{{flow.ha_discharge_start2_time}}","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"start","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":800,"y":2700,"wires":[["7abb2a45.685d54"]]},{"id":"7abb2a45.685d54","type":"api-current-state","z":"2abb1f4f.a17b3","name":"","server":"e9933ddd.73d49","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"{{flow.ha_discharge_stop2_time}}","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"finish","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":480,"y":2740,"wires":[["1096208d.af281f"]]},{"id":"1096208d.af281f","type":"api-current-state","z":"2abb1f4f.a17b3","name":"","server":"e9933ddd.73d49","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"{{flow.ha_dischargeTarget}}","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"dischargeToPercent","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":860,"y":2740,"wires":[["81c9e0dc.eee7b"]]},{"id":"f882f71e.a5e668","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Charge Enable","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":2,"entityType":"switch","config":[{"property":"name","value":"GivEnergy Charge Enable"},{"property":"device_class","value":"power"},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"kW"},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":true,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":810,"y":2380,"wires":[["dacc5833.9dffa8"],["9633586e.034a18"]]},{"id":"8c0a7e89.01a03","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Discharge Enable","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":2,"entityType":"switch","config":[{"property":"name","value":"GivEnergy Discharge Enable"},{"property":"device_class","value":"power"},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"kW"},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":true,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":800,"y":2460,"wires":[["1856d5d.cfe842a"],["456161a6.68dd3"]]},{"id":"b98b619a.4e197","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Set Charge Timings","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":2,"entityType":"switch","config":[{"property":"name","value":"GivEnergy Set Charge Timings"},{"property":"device_class","value":"power"},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"kW"},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":true,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":430,"y":2780,"wires":[["ff640b5e.05b878"],[]]},{"id":"c6de11e6.f74a2","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Set Discharge Timings 1","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":2,"entityType":"switch","config":[{"property":"name","value":"GivEnergy Set Discharge Timings Slot1"},{"property":"device_class","value":"power"},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"kW"},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":true,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":440,"y":2620,"wires":[["f55ffe72.b2edb"],[]]},{"id":"5f18b241.3ce28c","type":"inject","z":"2abb1f4f.a17b3","name":"StartUp","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":220,"y":2560,"wires":[["f882f71e.a5e668","8c0a7e89.01a03","c6de11e6.f74a2","b98b619a.4e197","98fc8402.dbda18"]]},{"id":"98fc8402.dbda18","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Set Discharge Timings 2","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":2,"entityType":"switch","config":[{"property":"name","value":"GivEnergy Set Discharge Timings Slot2"},{"property":"device_class","value":"power"},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"kW"},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":true,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":440,"y":2700,"wires":[["1650c494.e2ef7b"],[]]},{"id":"36b703f4.38842c","type":"server-events","z":"2abb1f4f.a17b3","name":"","server":"e9933ddd.73d49","version":1,"event_type":"state_changed","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"waitForRunning":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"$outputData(\"eventData\").event_type","valueType":"jsonata"},{"property":"event_type","propertyType":"msg","value":"$outputData(\"eventData\").event_type","valueType":"jsonata"}],"x":840,"y":2580,"wires":[["e662eab8.3ff538"]]},{"id":"e662eab8.3ff538","type":"switch","z":"2abb1f4f.a17b3","name":"Check if SOC entity","property":"payload.entity_id","propertyType":"msg","rules":[{"t":"eq","v":"ha_dischargeTarget","vt":"flow"}],"checkall":"true","repair":false,"outputs":1,"x":1050,"y":2580,"wires":[["304c6bc2.038944"]]},{"id":"304c6bc2.038944","type":"function","z":"2abb1f4f.a17b3","name":"","func":"msg.function=\"setBatteryReserve\";\nmsg.dischargeToPercent=Number(msg.payload.event.new_state.state).toFixed()\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1220,"y":2580,"wires":[["7026794c.a0ffd8"]]},{"id":"7026794c.a0ffd8","type":"template","z":"2abb1f4f.a17b3","name":"Battery Reserve template","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\"dischargeToPercent\":\"{{dischargeToPercent}}\"}","output":"str","x":1430,"y":2580,"wires":[["427f7094.5e15b"]]},{"id":"9e0f1042.8a6d1","type":"comment","z":"2abb1f4f.a17b3","name":"Set Battery Reserve from HA","info":"","x":580,"y":2580,"wires":[]},{"id":"648c0c89.1b6d84","type":"function","z":"2abb1f4f.a17b3","name":"","func":"msg.function=\"setDischargeSlot1\";\nmsg.start=msg.start.substring(0,5).replace(\":\",\"\")\nmsg.finish=msg.finish.substring(0,5).replace(\":\",\"\")\nmsg.target=Number(msg.dischargeToPercent).toFixed()\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1140,"y":2660,"wires":[["d63c6495.068fa8","438ed649.7319a8"]]},{"id":"81c9e0dc.eee7b","type":"function","z":"2abb1f4f.a17b3","name":"","func":"msg.function=\"setDischargeSlot2\";\nmsg.start=msg.start.substring(0,5).replace(\":\",\"\")\nmsg.finish=msg.finish.substring(0,5).replace(\":\",\"\")\nmsg.target=Number(msg.dischargeToPercent).toFixed()\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1140,"y":2740,"wires":[["d63c6495.068fa8","7a4f15b3.f7c71c"]]},{"id":"caafad6.849d65","type":"function","z":"2abb1f4f.a17b3","name":"","func":"msg.function=\"setChargeSlot1\";\nmsg.start=msg.start.substring(0,5).replace(\":\",\"\")\nmsg.finish=msg.finish.substring(0,5).replace(\":\",\"\")\nmsg.target=Number(msg.chargeToPercent).toFixed()\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1140,"y":2820,"wires":[["d04bfc39.c7b44","4b665144.4d501"]]},{"id":"b4d8fa50.4c6128","type":"rbe","z":"2abb1f4f.a17b3","name":"","func":"narrowbandEq","gap":"50%","start":"","inout":"out","septopics":true,"property":"payload.chargeUpTo","topi":"topic","x":1130,"y":1140,"wires":[["ac0df03f.9365f"]]},{"id":"d97d14f1.068168","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery Charge Total kWh","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Battery Charge Total kWh"},{"property":"device_class","value":"energy"},{"property":"icon","value":"mdi:battery-charging"},{"property":"unit_of_measurement","value":"kWh"},{"property":"state_class","value":"total_increasing"},{"property":"last_reset","value":""}],"state":"payload.batteryChargeTotal","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1850,"y":1860,"wires":[[]]},{"id":"ff3fe977.0059a8","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery Charge Today kWh","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Battery Charge Today kWh"},{"property":"device_class","value":"energy"},{"property":"icon","value":"mdi:battery-charging"},{"property":"unit_of_measurement","value":"kWh"},{"property":"state_class","value":"total_increasing"},{"property":"last_reset","value":""}],"state":"payload.battChargeToday","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1430,"y":1860,"wires":[[]]},{"id":"2226d527.81c3ea","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery Discharge Total kWh","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Battery Discharge Total kWh"},{"property":"device_class","value":"energy"},{"property":"icon","value":"mdi:battery-charging"},{"property":"unit_of_measurement","value":"kWh"},{"property":"state_class","value":"total_increasing"},{"property":"last_reset","value":""}],"state":"payload.battDisChargeTotal","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1860,"y":1920,"wires":[[]]},{"id":"401cb9b0.1282d8","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery Discharge Today kWh","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Battery Discharge Today kWh"},{"property":"device_class","value":"energy"},{"property":"icon","value":"mdi:battery-charging"},{"property":"unit_of_measurement","value":"kWh"},{"property":"state_class","value":"total_increasing"},{"property":"last_reset","value":""}],"state":"payload.battDisChargeToday","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1440,"y":1920,"wires":[[]]},{"id":"2b9eba9e.09dfc6","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Import Today kWh","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Import Today kWh"},{"property":"device_class","value":"energy"},{"property":"icon","value":"mdi:transmission-tower"},{"property":"unit_of_measurement","value":"kWh"},{"property":"state_class","value":"total_increasing"},{"property":"last_reset","value":""}],"state":"payload.importEnergyToday","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1400,"y":1980,"wires":[[]]},{"id":"75820a86.88cb34","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Import Total kWh","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Import Total kWh"},{"property":"device_class","value":"energy"},{"property":"icon","value":"mdi:transmission-tower"},{"property":"unit_of_measurement","value":"kWh"},{"property":"state_class","value":"total_increasing"},{"property":"last_reset","value":""}],"state":"payload.importEnergyTotal","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1820,"y":1980,"wires":[[]]},{"id":"437fae39.b6419","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Export Today kWh","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Export Today kWh"},{"property":"device_class","value":"energy"},{"property":"icon","value":"mdi:transmission-tower"},{"property":"unit_of_measurement","value":"kWh"},{"property":"state_class","value":"total_increasing"},{"property":"last_reset","value":""}],"state":"payload.exportEnergyToday","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1400,"y":2040,"wires":[[]]},{"id":"d71a2d64.96f11","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Export Total kWh","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Export Total kWh"},{"property":"device_class","value":"energy"},{"property":"icon","value":"mdi:transmission-tower"},{"property":"unit_of_measurement","value":"kWh"},{"property":"state_class","value":"total_increasing"},{"property":"last_reset","value":""}],"state":"payload.exportEnergyTotal","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1820,"y":2040,"wires":[[]]},{"id":"468bed14.371834","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Load Total kWh","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Load Total kWh"},{"property":"device_class","value":"energy"},{"property":"icon","value":"mdi:home-lightbulb"},{"property":"unit_of_measurement","value":"kWh"},{"property":"state_class","value":"total_increasing"},{"property":"last_reset","value":""}],"state":"payload.loadEnergyTotal","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1820,"y":2100,"wires":[[]]},{"id":"b4d6ae26.979d1","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Load Today kWh","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Load Today kWh"},{"property":"device_class","value":"energy"},{"property":"icon","value":"mdi:home-lightbulb"},{"property":"unit_of_measurement","value":"kWh"},{"property":"state_class","value":"total_increasing"},{"property":"last_reset","value":""}],"state":"payload.loadEnergyToday","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1400,"y":2100,"wires":[[]]},{"id":"966647f4.04d118","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy PV Total kWh","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy PV Total kWh"},{"property":"device_class","value":"energy"},{"property":"icon","value":"mdi:solar-power"},{"property":"unit_of_measurement","value":"kWh"},{"property":"state_class","value":"total_increasing"},{"property":"last_reset","value":""}],"state":"payload.pvEnergyTotal","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1810,"y":2160,"wires":[[]]},{"id":"dcaf40a0.f5765","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery Throughput Total kWh","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Battery ThroughputTotal kWh"},{"property":"device_class","value":"energy"},{"property":"icon","value":"mdi:solar-power"},{"property":"unit_of_measurement","value":"kWh"},{"property":"state_class","value":"total_increasing"},{"property":"last_reset","value":""}],"state":"payload.batteryThouTotal","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1860,"y":2220,"wires":[[]]},{"id":"c100e026.a2d49","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery Throughput Today kWh","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Battery Throughput Today kWh"},{"property":"device_class","value":"energy"},{"property":"icon","value":"mdi:solar-power"},{"property":"unit_of_measurement","value":"kWh"},{"property":"state_class","value":"total_increasing"},{"property":"last_reset","value":""}],"state":"payload.batteryThouToday","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1440,"y":2220,"wires":[[]]},{"id":"80271b84.588788","type":"function","z":"2abb1f4f.a17b3","name":"","func":"msg.function=\"resumeChargeSchedule\";\nmsg.payload={}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1220,"y":2360,"wires":[["427f7094.5e15b"]]},{"id":"584f7bd9.7fa6a4","type":"function","z":"2abb1f4f.a17b3","name":"","func":"msg.function=\"pauseDischargeSchedule\";\nmsg.payload={}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1220,"y":2480,"wires":[["427f7094.5e15b"]]},{"id":"dcc3e844.9cd8b8","type":"function","z":"2abb1f4f.a17b3","name":"","func":"msg.function=\"resumeDischargeSchedule\";\nmsg.payload={}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1220,"y":2440,"wires":[["427f7094.5e15b"]]},{"id":"dacc5833.9dffa8","type":"rbe","z":"2abb1f4f.a17b3","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","x":1070,"y":2360,"wires":[["80271b84.588788"]]},{"id":"9633586e.034a18","type":"rbe","z":"2abb1f4f.a17b3","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","x":1070,"y":2400,"wires":[["9ac0dcfd.10bf7"]]},{"id":"1856d5d.cfe842a","type":"rbe","z":"2abb1f4f.a17b3","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","x":1070,"y":2440,"wires":[["dcc3e844.9cd8b8"]]},{"id":"456161a6.68dd3","type":"rbe","z":"2abb1f4f.a17b3","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","x":1070,"y":2480,"wires":[["584f7bd9.7fa6a4"]]},{"id":"79e8996f.211b48","type":"rbe","z":"2abb1f4f.a17b3","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","x":1450,"y":1020,"wires":[["235853e8.70e02c"]]},{"id":"ca7a8960.33bca8","type":"rbe","z":"2abb1f4f.a17b3","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","x":1450,"y":1080,"wires":[["e1dc315f.8eef9"]]},{"id":"ac0df03f.9365f","type":"rbe","z":"2abb1f4f.a17b3","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":1290,"y":1140,"wires":[["b5a38cee.997ac"]]},{"id":"67f54a03.9c0b94","type":"rbe","z":"2abb1f4f.a17b3","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":1290,"y":1200,"wires":[["d85d002d.58ee3"]]},{"id":"71647975.c7e8d8","type":"rbe","z":"2abb1f4f.a17b3","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","x":1290,"y":1260,"wires":[["6d3c2068.2a7ea"]]},{"id":"a04f196e.1bf378","type":"rbe","z":"2abb1f4f.a17b3","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":1330,"y":1380,"wires":[["57396101.ba8fe"]]},{"id":"46c08530.905a8c","type":"rbe","z":"2abb1f4f.a17b3","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","x":1330,"y":1440,"wires":[["68d7fb75.7443b4"]]},{"id":"d93a567f.923878","type":"rbe","z":"2abb1f4f.a17b3","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","x":1330,"y":1500,"wires":[["ae4d7a7b.e17188"]]},{"id":"b285445b.4d2c38","type":"rbe","z":"2abb1f4f.a17b3","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","x":1330,"y":1560,"wires":[["70dc658d.7e3d7c"]]},{"id":"c48e9b5e.9eea78","type":"rbe","z":"2abb1f4f.a17b3","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","x":1330,"y":1620,"wires":[["3c86d5fa.324caa"]]},{"id":"f6a69f01.644fc","type":"rbe","z":"2abb1f4f.a17b3","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","x":1330,"y":1680,"wires":[["ada347da.e92dd8"]]},{"id":"438ed649.7319a8","type":"api-call-service","z":"2abb1f4f.a17b3","name":"reset timing switch","server":"e9933ddd.73d49","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":[],"entityId":["switch.givenergy_set_discharge_timings_slot1"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"data"}],"queue":"none","x":1350,"y":2640,"wires":[[]]},{"id":"7a4f15b3.f7c71c","type":"api-call-service","z":"2abb1f4f.a17b3","name":"reset timing switch","server":"e9933ddd.73d49","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":[],"entityId":["switch.givenergy_set_discharge_timings_slot2"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"data"}],"queue":"none","x":1350,"y":2740,"wires":[[]]},{"id":"4b665144.4d501","type":"api-call-service","z":"2abb1f4f.a17b3","name":"reset timing switch","server":"e9933ddd.73d49","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":[],"entityId":["switch.givenergy_set_charge_timings"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"data"}],"queue":"none","x":1330,"y":2860,"wires":[[]]},{"id":"528669e8.4881e8","type":"debug","z":"2abb1f4f.a17b3","name":"Battery","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":980,"y":2000,"wires":[]},{"id":"12db4aed.b5b915","type":"file","z":"2abb1f4f.a17b3","name":"","filename":"/config/giv_tcp/solarcheck.log","filenameType":"str","appendNewline":true,"createDir":true,"overwriteFile":"false","encoding":"none","x":1580,"y":260,"wires":[[]]},{"id":"36c69f3.5090e6","type":"switch","z":"2abb1f4f.a17b3","name":"","property":"flowCheck[1]","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1090,"y":260,"wires":[[],["bdd91b3c.35d8e8","c076003b.e2ed1"]]},{"id":"bdd91b3c.35d8e8","type":"function","z":"2abb1f4f.a17b3","name":"","func":"var stats={}\nstats=msg.payload\nmsg.payload={}\nmsg.payload.timestamp=msg.timestamp=new Date().toISOString().replace(/T/, ' ').replace(/\\..+/, '')\nmsg.payload.flowcheck=msg.flowCheck\nmsg.payload.stats=stats\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1280,"y":260,"wires":[["12db4aed.b5b915"]]},{"id":"972115f0.3719d8","type":"switch","z":"2abb1f4f.a17b3","name":"","property":"payload","propertyType":"msg","rules":[{"t":"neq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":1130,"y":1200,"wires":[["67f54a03.9c0b94"]]},{"id":"db70053c.158368","type":"http request","z":"2abb1f4f.a17b3","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"x":490,"y":1200,"wires":[["f0c4f8.1c0b9b08"]]},{"id":"f4d7b76b.6334d8","type":"inject","z":"2abb1f4f.a17b3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"10","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":70,"y":1200,"wires":[["d4719165.f8b69"]]},{"id":"f0c4f8.1c0b9b08","type":"json","z":"2abb1f4f.a17b3","name":"","property":"payload","action":"","pretty":false,"x":630,"y":1200,"wires":[["39757357.04fb3c","c7caf11c.89579","58657be9.ff1324","1c94a5e7.01b17a","1e6a680221065c41","04c0915da6cbe653"]]},{"id":"39757357.04fb3c","type":"debug","z":"2abb1f4f.a17b3","name":"Data","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":930,"y":1260,"wires":[]},{"id":"43b46379.32fb8c","type":"link in","z":"2abb1f4f.a17b3","name":"","links":["26f0945e.1b1a2c","1e6a680221065c41"],"x":805,"y":2060,"wires":[["528669e8.4881e8","8f918a1514ef312f"]]},{"id":"870b4227.1554","type":"change","z":"2abb1f4f.a17b3","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.ChargeFlag","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1300,"y":1020,"wires":[["79e8996f.211b48"]]},{"id":"74cf8a57.8ebd24","type":"change","z":"2abb1f4f.a17b3","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.DischargeFlag","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1300,"y":1080,"wires":[["ca7a8960.33bca8"]]},{"id":"c59c6aa8.00a6a8","type":"debug","z":"2abb1f4f.a17b3","name":"InfluxData","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1040,"y":1700,"wires":[]},{"id":"91c3dd02.ae664","type":"inject","z":"2abb1f4f.a17b3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":760,"wires":[["d3f5403e75968d65"]]},{"id":"fa7741f7.d51c3","type":"json","z":"2abb1f4f.a17b3","name":"","property":"payload","action":"","pretty":true,"x":390,"y":760,"wires":[["825e99d4.5202e8"]]},{"id":"825e99d4.5202e8","type":"debug","z":"2abb1f4f.a17b3","name":"Test","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":530,"y":760,"wires":[]},{"id":"de11890.0978778","type":"http request","z":"2abb1f4f.a17b3","name":"","method":"POST","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"x":1950,"y":2540,"wires":[["be93c972.d3a2e8"]]},{"id":"427f7094.5e15b","type":"function","z":"2abb1f4f.a17b3","name":"Set Write Call URL","func":"const base_url= flow.get(\"giv_tcp_base_url\")\nmsg.url=base_url + \"/\" + msg.function\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1770,"y":2540,"wires":[["de11890.0978778","be93c972.d3a2e8"]]},{"id":"f3b96683.9c14a8","type":"function","z":"2abb1f4f.a17b3","name":"Set URL","func":"const base_url= flow.get(\"giv_tcp_base_url\")\nmsg.url=base_url + \"/\" + msg.function\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":340,"y":1200,"wires":[["db70053c.158368"]]},{"id":"d4719165.f8b69","type":"change","z":"2abb1f4f.a17b3","name":"runAll","rules":[{"t":"set","p":"function","pt":"msg","to":"runAll","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":210,"y":1200,"wires":[["f3b96683.9c14a8"]]},{"id":"b3a295b2e80a4366","type":"debug","z":"2abb1f4f.a17b3","name":"Solar to house","active":true,"tosidebar":true,"console":true,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":3840,"y":160,"wires":[]},{"id":"1e6a680221065c41","type":"link out","z":"2abb1f4f.a17b3","name":"","mode":"link","links":["43b46379.32fb8c"],"x":655,"y":2060,"wires":[]},{"id":"ed0ee394ae18a80c","type":"http request","z":"2abb1f4f.a17b3","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"x":470,"y":860,"wires":[["fa7741f7.d51c3"]]},{"id":"78dd66412b326b7a","type":"function","z":"2abb1f4f.a17b3","name":"Set URL","func":"const base_url= flow.get(\"giv_tcp_base_url\")\nmsg.url=base_url + \"/\" + msg.function\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":300,"y":860,"wires":[["ed0ee394ae18a80c"]]},{"id":"d3f5403e75968d65","type":"change","z":"2abb1f4f.a17b3","name":"DataString","rules":[{"t":"set","p":"function","pt":"msg","to":"runAll","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":150,"y":860,"wires":[["78dd66412b326b7a"]]},{"id":"edfc915bb747efc8","type":"link in","z":"2abb1f4f.a17b3","name":"","links":["26f0945e.1b1a2c","04c0915da6cbe653"],"x":1895,"y":1380,"wires":[["fe70cde78ce99327"]]},{"id":"bba41a9017bd2bf4","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery Voltage Cell 1","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Battery Voltage Cell 1"},{"property":"device_class","value":"voltage"},{"property":"icon","value":"mdi:battery"},{"property":"unit_of_measurement","value":"V"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.voltageCell1","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2440,"y":1080,"wires":[[]]},{"id":"04c0915da6cbe653","type":"link out","z":"2abb1f4f.a17b3","name":"","mode":"link","links":["9b4e1b8229d6f1b0","613c3645ca78d866","edfc915bb747efc8"],"x":1655,"y":1320,"wires":[]},{"id":"174c90352b5db07d","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery Voltage Cell 2","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Battery Voltage Cell 2"},{"property":"device_class","value":"voltage"},{"property":"icon","value":"mdi:battery"},{"property":"unit_of_measurement","value":"V"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.voltageCell2","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2440,"y":1140,"wires":[[]]},{"id":"ff599952c70d9862","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery Voltage Cell 3","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Battery Voltage Cell 3"},{"property":"device_class","value":"voltage"},{"property":"icon","value":"mdi:battery"},{"property":"unit_of_measurement","value":"V"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.voltageCell3","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2440,"y":1200,"wires":[[]]},{"id":"dbd2ec640eb7f677","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery Voltage Cell 4","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Battery Voltage Cell 4"},{"property":"device_class","value":"voltage"},{"property":"icon","value":"mdi:battery"},{"property":"unit_of_measurement","value":"V"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.voltageCell4","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2440,"y":1260,"wires":[[]]},{"id":"12e10b3966f239d9","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery Voltage Cell 5","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Battery Voltage Cell 5"},{"property":"device_class","value":"voltage"},{"property":"icon","value":"mdi:battery"},{"property":"unit_of_measurement","value":"V"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.voltageCell5","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2440,"y":1320,"wires":[[]]},{"id":"1e0a3085e9a230a0","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery Voltage Cell 6","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Battery Voltage Cell 6"},{"property":"device_class","value":"voltage"},{"property":"icon","value":"mdi:battery"},{"property":"unit_of_measurement","value":"V"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.voltageCell6","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2440,"y":1380,"wires":[[]]},{"id":"76c3e67e17050265","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery Voltage Cell 7","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Battery Voltage Cell 7"},{"property":"device_class","value":"voltage"},{"property":"icon","value":"mdi:battery"},{"property":"unit_of_measurement","value":"V"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.voltageCell7","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2440,"y":1440,"wires":[[]]},{"id":"df9733c7faa329b3","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery Voltage Cell 8","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Battery Voltage Cell 8"},{"property":"device_class","value":"voltage"},{"property":"icon","value":"mdi:battery"},{"property":"unit_of_measurement","value":"V"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.voltageCell8","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2440,"y":1500,"wires":[[]]},{"id":"8c102a9b0a06534c","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery Voltage Cell 9","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Battery Voltage Cell 9"},{"property":"device_class","value":"voltage"},{"property":"icon","value":"mdi:battery"},{"property":"unit_of_measurement","value":"V"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.voltageCell9","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2440,"y":1560,"wires":[[]]},{"id":"68b83f682f641399","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery Voltage Cell 10","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Battery Voltage Cell 10"},{"property":"device_class","value":"voltage"},{"property":"icon","value":"mdi:battery"},{"property":"unit_of_measurement","value":"V"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.voltageCell10","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2440,"y":1620,"wires":[[]]},{"id":"6c6f22e66e39723a","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery Voltage Cell 11","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Battery Voltage Cell 11"},{"property":"device_class","value":"voltage"},{"property":"icon","value":"mdi:battery"},{"property":"unit_of_measurement","value":"V"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.voltageCell11","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2440,"y":1680,"wires":[[]]},{"id":"b715efc95744e7c7","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery Voltage Cell 12","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Battery Voltage Cell 12"},{"property":"device_class","value":"voltage"},{"property":"icon","value":"mdi:battery"},{"property":"unit_of_measurement","value":"V"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.voltageCell12","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2440,"y":1740,"wires":[[]]},{"id":"0575d0f8ee2de1d6","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery Voltage Cell 13","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Battery Voltage Cell 13"},{"property":"device_class","value":"voltage"},{"property":"icon","value":"mdi:battery"},{"property":"unit_of_measurement","value":"V"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.voltageCell13","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2440,"y":1800,"wires":[[]]},{"id":"e741e9bd671b52a7","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery Voltage Cell 14","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Battery Voltage Cell 14"},{"property":"device_class","value":"voltage"},{"property":"icon","value":"mdi:battery"},{"property":"unit_of_measurement","value":"V"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.voltageCell14","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2440,"y":1860,"wires":[[]]},{"id":"a6d15be0b55267ae","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery Voltage Cell 15","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Battery Voltage Cell 15"},{"property":"device_class","value":"voltage"},{"property":"icon","value":"mdi:battery"},{"property":"unit_of_measurement","value":"V"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.voltageCell15","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2440,"y":1920,"wires":[[]]},{"id":"26d1286036e2221a","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery Voltage Cell 16","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Battery Voltage Cell 16"},{"property":"device_class","value":"voltage"},{"property":"icon","value":"mdi:battery"},{"property":"unit_of_measurement","value":"V"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.voltageCell16","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2440,"y":1980,"wires":[[]]},{"id":"44158c9ccaa3dfb4","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery Voltage","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Battery Voltage"},{"property":"device_class","value":"voltage"},{"property":"icon","value":"mdi:battery"},{"property":"unit_of_measurement","value":"V"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.batteryVoltage","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2420,"y":2040,"wires":[[]]},{"id":"23306d246889b4f5","type":"comment","z":"2abb1f4f.a17b3","name":"runAll","info":"","x":1910,"y":1340,"wires":[]},{"id":"b286a9cfc2adccbd","type":"comment","z":"2abb1f4f.a17b3","name":"Battery Voltage information","info":"","x":2450,"y":1020,"wires":[]},{"id":"9b4e1b8229d6f1b0","type":"link in","z":"2abb1f4f.a17b3","name":"","links":["26f0945e.1b1a2c","04c0915da6cbe653"],"x":2735,"y":1320,"wires":[["e0fd582debc6cd9a","febaaff23a5c9206"]]},{"id":"54102f72f89ffc21","type":"ha-entity","z":"2abb1f4f.a17b3","name":"Battery Firmware","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Battery Firmware"},{"property":"device_class","value":"battery"},{"property":"icon","value":"mdi:battery"},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"payload.batteryFirmware","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":3290,"y":1120,"wires":[[]]},{"id":"c8fc87ef0a40de62","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery Capacity","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Battery Capacity"},{"property":"device_class","value":"energy"},{"property":"icon","value":"mdi:battery"},{"property":"unit_of_measurement","value":"kWh"},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"payload.batteryCapacity","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":3320,"y":1180,"wires":[[]]},{"id":"268b1088c059cf10","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery Temperature Cells 1","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Battery Temperature Cells 1"},{"property":"device_class","value":"temperature"},{"property":"icon","value":"mdi:thermometer"},{"property":"unit_of_measurement","value":"°C"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.tempCell1","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":3350,"y":1300,"wires":[[]]},{"id":"47892395999ebd77","type":"comment","z":"2abb1f4f.a17b3","name":"runAll","info":"","x":2700,"y":1280,"wires":[]},{"id":"dc6a02e74f679a9b","type":"comment","z":"2abb1f4f.a17b3","name":"Battery information","info":"","x":3290,"y":1060,"wires":[]},{"id":"4a8d7558f0ac8268","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Inverter Temperature","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Inverter Temperature"},{"property":"device_class","value":"temperature"},{"property":"icon","value":"mdi:thermometer"},{"property":"unit_of_measurement","value":"°C"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.invertorTemp","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":3330,"y":1240,"wires":[[]]},{"id":"8243fe775e8a2c2f","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery Temperature Cells 2","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Battery Temperature Cells 2"},{"property":"device_class","value":"temperature"},{"property":"icon","value":"mdi:thermometer"},{"property":"unit_of_measurement","value":"°C"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.tempCell2","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":3350,"y":1360,"wires":[[]]},{"id":"1e617fa8dd8200d6","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery Temperature Cells 3","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Battery Temperature Cells 3"},{"property":"device_class","value":"temperature"},{"property":"icon","value":"mdi:thermometer"},{"property":"unit_of_measurement","value":"°C"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.tempCell3","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":3350,"y":1420,"wires":[[]]},{"id":"fd5b5f3e5a1c4268","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Battery Temperature Cells 4","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Battery Temperature Cells 4"},{"property":"device_class","value":"temperature"},{"property":"icon","value":"mdi:thermometer"},{"property":"unit_of_measurement","value":"°C"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.tempCell4","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":3350,"y":1480,"wires":[[]]},{"id":"613c3645ca78d866","type":"link in","z":"2abb1f4f.a17b3","name":"","links":["26f0945e.1b1a2c","04c0915da6cbe653"],"x":2735,"y":1820,"wires":[["a7e76a5cdf03733a"]]},{"id":"e5930f1f267e439c","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy String 1 Voltage","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy String 1 Voltage"},{"property":"device_class","value":"voltage"},{"property":"icon","value":"mdi:solar-panel"},{"property":"unit_of_measurement","value":"V"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.voltageString1","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":3320,"y":1680,"wires":[[]]},{"id":"e2600f48bd627ff3","type":"comment","z":"2abb1f4f.a17b3","name":"runAll","info":"","x":2700,"y":1780,"wires":[]},{"id":"e92732196bcd78ff","type":"comment","z":"2abb1f4f.a17b3","name":"Inverter information","info":"","x":3310,"y":1640,"wires":[]},{"id":"dd19191ace9e8d9e","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy String 2 Voltage","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy String 2 Voltage"},{"property":"device_class","value":"voltage"},{"property":"icon","value":"mdi:solar-panel"},{"property":"unit_of_measurement","value":"V"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.voltageString2","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":3320,"y":1740,"wires":[[]]},{"id":"5733363879607322","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy String 1 Current","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy String 1 Current"},{"property":"device_class","value":"current"},{"property":"icon","value":"mdi:solar-panel"},{"property":"unit_of_measurement","value":"A"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.currentString1","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":3320,"y":1800,"wires":[[]]},{"id":"cc68848c95fcbe5f","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy String 2 Current","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy String 2 Current"},{"property":"device_class","value":"current"},{"property":"icon","value":"mdi:solar-panel"},{"property":"unit_of_measurement","value":"A"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.currentString2","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":3320,"y":1860,"wires":[[]]},{"id":"a9ef9f93ec4dad66","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Inverter Heatsink Temp","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Inverter Heatsink Temperature"},{"property":"device_class","value":"temperature"},{"property":"icon","value":"mdi:thermometer"},{"property":"unit_of_measurement","value":"°C"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.heatSinkTemp","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":3340,"y":2040,"wires":[[]]},{"id":"688f7330a341c2c5","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy Charge Temp","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy Charger Temperature"},{"property":"device_class","value":"temperature"},{"property":"icon","value":"mdi:thermometer"},{"property":"unit_of_measurement","value":"°C"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.chargeTemp","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":3310,"y":2100,"wires":[[]]},{"id":"e0fd582debc6cd9a","type":"function","z":"2abb1f4f.a17b3","name":"Battery Information","func":"var batterySerial = flow.get(\"battery_Serial\")\n\n\n\nvar batteryFirmware = Number(msg.payload['Battery_Details'][batterySerial]['Battery_Firmware_Version']);\nvar batteryCapacity = Number(msg.payload['Invertor_Details']['Battery_Capacity_kWh']);\nvar invertorTemp = Number(msg.payload['Invertor_Details']['Invertor_Temperature']);\nvar tempCell1 = Number(msg.payload['Battery_Details'][batterySerial]['Battery_Cell_1_Temperature']);\nvar tempCell2 = Number(msg.payload['Battery_Details'][batterySerial]['Battery_Cell_2_Temperature']);\nvar tempCell3 = Number(msg.payload['Battery_Details'][batterySerial]['Battery_Cell_3_Temperature']);\nvar tempCell4 = Number(msg.payload['Battery_Details'][batterySerial]['Battery_Cell_4_Temperature']);\n\nmsg.payload = {};\n\nif (isNaN(batteryFirmware)== false) msg.payload.batteryFirmware = Number(batteryFirmware);\nif (isNaN(batteryCapacity)== false) msg.payload.batteryCapacity = Number(batteryCapacity);\nif (isNaN(invertorTemp)== false) msg.payload.invertorTemp = Number(invertorTemp);\nif (isNaN(tempCell1)== false) msg.payload.tempCell1 = Number(tempCell1);\nif (isNaN(tempCell2)== false) msg.payload.tempCell2 = Number(tempCell2);\nif (isNaN(tempCell3)== false) msg.payload.tempCell3 = Number(tempCell3);\nif (isNaN(tempCell4)== false) msg.payload.tempCell4 = Number(tempCell4);\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2910,"y":1320,"wires":[["54102f72f89ffc21","c8fc87ef0a40de62","4a8d7558f0ac8268","268b1088c059cf10","8243fe775e8a2c2f","1e617fa8dd8200d6","fd5b5f3e5a1c4268"]]},{"id":"a7e76a5cdf03733a","type":"function","z":"2abb1f4f.a17b3","name":"Inverter Information","func":"var batterySerial = flow.get(\"battery_Serial\")\n\n\nvar voltageString1 = Number(msg.payload['raw']['invertor']['v_pv1']);\nvar voltageString2 = Number(msg.payload['raw']['invertor']['v_pv2']);\nvar currentString1 = Number(msg.payload['raw']['invertor']['i_pv1']);\nvar currentString2 = Number(msg.payload['raw']['invertor']['i_pv2']);\nvar pvPower1 = Number(msg.payload['Power']['Power']['PV_Power_String_1']);\nvar pvPower2 = Number(msg.payload['Power']['Power']['PV_Power_String_2']);\nvar heatSinkTemp = Number(msg.payload['raw']['invertor']['temp_inverter_heatsink']);\nvar chargeTemp = Number(msg.payload['raw']['invertor']['temp_charger']);\n\n\nmsg.payload = {};\n\n\nif (isNaN(voltageString1)== false) msg.payload.voltageString1 = Number(voltageString1);\nif (isNaN(voltageString2)== false) msg.payload.voltageString2 = Number(voltageString2);\nif (isNaN(currentString1)== false) msg.payload.currentString1 = Number(currentString1);\nif (isNaN(currentString2)== false) msg.payload.currentString2 = Number(currentString2);\nif (isNaN(pvPower1)== false) msg.payload.pvPower1 = Number(pvPower1);\nif (isNaN(pvPower2)== false) msg.payload.pvPower2 = Number(pvPower2);\nif (isNaN(heatSinkTemp)== false) msg.payload.heatSinkTemp = Number(heatSinkTemp);\nif (isNaN(chargeTemp)== false) msg.payload.chargeTemp = Number(chargeTemp);\n\n\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2910,"y":1820,"wires":[["e5930f1f267e439c","dd19191ace9e8d9e","5733363879607322","cc68848c95fcbe5f","a9ef9f93ec4dad66","688f7330a341c2c5","5af83fbe4fc1d3d5","da919ca39e471a97","c19471b080bd18a4"]]},{"id":"5af83fbe4fc1d3d5","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy String 1 Power","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy String 1 Power"},{"property":"device_class","value":"power"},{"property":"icon","value":"mdi:solar-panel"},{"property":"unit_of_measurement","value":"W"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.pvPower1","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":3310,"y":1920,"wires":[[]]},{"id":"da919ca39e471a97","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy String 2 Power","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy String 2 Power"},{"property":"device_class","value":"power"},{"property":"icon","value":"mdi:solar-panel"},{"property":"unit_of_measurement","value":"W"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload.pvPower2","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":3310,"y":1980,"wires":[[]]},{"id":"c19471b080bd18a4","type":"debug","z":"2abb1f4f.a17b3","name":"Inverter info","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":3270,"y":2160,"wires":[]},{"id":"fe70cde78ce99327","type":"function","z":"2abb1f4f.a17b3","name":"Battery Information","func":"var batterySerial = flow.get(\"battery_Serial\")\n\nvar voltageCell1 = Number(msg.payload['Battery_Details'][batterySerial]['Battery_Cell_1_Voltage']).toFixed(2);\nvar voltageCell2 = Number(msg.payload['Battery_Details'][batterySerial]['Battery_Cell_2_Voltage']).toFixed(2);\nvar voltageCell3 = Number(msg.payload['Battery_Details'][batterySerial]['Battery_Cell_3_Voltage']).toFixed(2);\nvar voltageCell4 = Number(msg.payload['Battery_Details'][batterySerial]['Battery_Cell_4_Voltage']).toFixed(2);\nvar voltageCell5 = Number(msg.payload['Battery_Details'][batterySerial]['Battery_Cell_5_Voltage']).toFixed(2);\nvar voltageCell6 = Number(msg.payload['Battery_Details'][batterySerial]['Battery_Cell_6_Voltage']).toFixed(2);\nvar voltageCell7 = Number(msg.payload['Battery_Details'][batterySerial]['Battery_Cell_7_Voltage']).toFixed(2);\nvar voltageCell8 = Number(msg.payload['Battery_Details'][batterySerial]['Battery_Cell_8_Voltage']).toFixed(2);\nvar voltageCell9 = Number(msg.payload['Battery_Details'][batterySerial]['Battery_Cell_9_Voltage']).toFixed(2);\nvar voltageCell10 = Number(msg.payload['Battery_Details'][batterySerial]['Battery_Cell_10_Voltage']).toFixed(2);\nvar voltageCell11 = Number(msg.payload['Battery_Details'][batterySerial]['Battery_Cell_11_Voltage']).toFixed(2);\nvar voltageCell12 = Number(msg.payload['Battery_Details'][batterySerial]['Battery_Cell_12_Voltage']).toFixed(2);\nvar voltageCell13 = Number(msg.payload['Battery_Details'][batterySerial]['Battery_Cell_13_Voltage']).toFixed(2);\nvar voltageCell14 = Number(msg.payload['Battery_Details'][batterySerial]['Battery_Cell_14_Voltage']).toFixed(2);\nvar voltageCell15 = Number(msg.payload['Battery_Details'][batterySerial]['Battery_Cell_15_Voltage']).toFixed(2);\nvar voltageCell16 = Number(msg.payload['Battery_Details'][batterySerial]['Battery_Cell_16_Voltage']).toFixed(2);\nvar batteryVoltage = Number(msg.payload['Battery_Details'][batterySerial]['Battery_Voltage']).toFixed(2);\n\nmsg.payload = {};\n\nif (isNaN(voltageCell1)== false) msg.payload.voltageCell1 = Number(voltageCell1);\nif (isNaN(voltageCell2)== false) msg.payload.voltageCell2 = Number(voltageCell2);\nif (isNaN(voltageCell3)== false) msg.payload.voltageCell3 = Number(voltageCell3);\nif (isNaN(voltageCell4)== false) msg.payload.voltageCell4 = Number(voltageCell4);\nif (isNaN(voltageCell5)== false) msg.payload.voltageCell5 = Number(voltageCell5);\nif (isNaN(voltageCell6)== false) msg.payload.voltageCell6 = Number(voltageCell6);\nif (isNaN(voltageCell7)== false) msg.payload.voltageCell7 = Number(voltageCell7);\nif (isNaN(voltageCell8)== false) msg.payload.voltageCell8 = Number(voltageCell8);\nif (isNaN(voltageCell9)== false) msg.payload.voltageCell9 = Number(voltageCell9);\nif (isNaN(voltageCell10)== false) msg.payload.voltageCell10 = Number(voltageCell10);\nif (isNaN(voltageCell11)== false) msg.payload.voltageCell11 = Number(voltageCell11);\nif (isNaN(voltageCell12)== false) msg.payload.voltageCell12 = Number(voltageCell12);\nif (isNaN(voltageCell13)== false) msg.payload.voltageCell13 = Number(voltageCell13);\nif (isNaN(voltageCell14)== false) msg.payload.voltageCell14 = Number(voltageCell14);\nif (isNaN(voltageCell15)== false) msg.payload.voltageCell15 = Number(voltageCell15);\nif (isNaN(voltageCell16)== false) msg.payload.voltageCell16 = Number(voltageCell16);\nif (isNaN(batteryVoltage)== false) msg.payload.batteryVoltage = Number(batteryVoltage);\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2070,"y":1500,"wires":[["bba41a9017bd2bf4","174c90352b5db07d","ff599952c70d9862","dbd2ec640eb7f677","12e10b3966f239d9","1e0a3085e9a230a0","76c3e67e17050265","df9733c7faa329b3","8c102a9b0a06534c","68b83f682f641399","6c6f22e66e39723a","b715efc95744e7c7","0575d0f8ee2de1d6","e741e9bd671b52a7","a6d15be0b55267ae","26d1286036e2221a","44158c9ccaa3dfb4"]]},{"id":"8f918a1514ef312f","type":"function","z":"2abb1f4f.a17b3","name":"Invertor Information","func":"var battChargeToday = Number(msg.payload['Energy']['Today']['Battery_Charge_Energy_Today_kWh']);\nvar battDisChargeToday = Number(msg.payload['Energy']['Today']['Battery_Discharge_Energy_Today_kWh']);\nvar importEnergyToday = Number(msg.payload['Energy']['Today']['Import_Energy_Today_kWh']);\nvar exportEnergyToday = Number(msg.payload['Energy']['Today']['Export_Energy_Today_kWh']);\nvar loadEnergyToday = Number(msg.payload['Energy']['Today']['Load_Energy_Today_kWh']);\nvar pvEnergyToday = Number(msg.payload['Energy']['Today']['PV_Energy_Today_kWh']);\nvar batteryThouToday = Number(msg.payload['Energy']['Today']['Battery_Throughput_Today_kWh']);\nvar batteryChargeTotal = Number(msg.payload['Energy']['Total']['Battery_Charge_Energy_Total_kWh']);\nvar battDisChargeTotal = Number(msg.payload['Energy']['Total']['Battery_Discharge_Energy_Total_kWh']);\nvar importEnergyTotal = Number(msg.payload['Energy']['Total']['Import_Energy_Total_kWh']);\nvar exportEnergyTotal = Number(msg.payload['Energy']['Total']['Export_Energy_Total_kWh']);\nvar loadEnergyTotal = Number(msg.payload['Energy']['Total']['Load_Energy_Total_kWh']);\nvar pvEnergyTotal = Number(msg.payload['Energy']['Total']['PV_Energy_Total_kWh']);\nvar batteryThouTotal = Number(msg.payload['Energy']['Total']['Battery_Throughput_Total_kWh']);\n\nmsg.payload = {};\n\nif (isNaN(battChargeToday)== false) msg.payload.battChargeToday = Number(battChargeToday);\nif (isNaN(battDisChargeToday)== false) msg.payload.battDisChargeToday = Number(battDisChargeToday);\nif (isNaN(importEnergyToday)== false) msg.payload.importEnergyToday = Number(importEnergyToday);\nif (isNaN(exportEnergyToday)== false) msg.payload.exportEnergyToday = Number(exportEnergyToday);\nif (isNaN(loadEnergyToday)== false) msg.payload.loadEnergyToday = Number(loadEnergyToday);\nif (isNaN(pvEnergyToday)== false) msg.payload.pvEnergyToday = Number(pvEnergyToday);\nif (isNaN(batteryThouToday)== false) msg.payload.batteryThouToday = Number(batteryThouToday);\nif (isNaN(batteryChargeTotal)== false) msg.payload.batteryChargeTotal = Number(batteryChargeTotal);\nif (isNaN(battDisChargeTotal)== false) msg.payload.battDisChargeTotal = Number(battDisChargeTotal);\nif (isNaN(importEnergyTotal)== false) msg.payload.importEnergyTotal = Number(importEnergyTotal);\nif (isNaN(exportEnergyTotal)== false) msg.payload.exportEnergyTotal = Number(exportEnergyTotal);\nif (isNaN(loadEnergyTotal)== false) msg.payload.loadEnergyTotal = Number(loadEnergyTotal);\nif (isNaN(pvEnergyTotal)== false) msg.payload.pvEnergyTotal = Number(pvEnergyTotal);\nif (isNaN(batteryThouTotal)== false) msg.payload.batteryThouTotal = Number(batteryThouTotal);\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1010,"y":2060,"wires":[["ff3fe977.0059a8","401cb9b0.1282d8","2b9eba9e.09dfc6","437fae39.b6419","b4d6ae26.979d1","c100e026.a2d49","d97d14f1.068168","2226d527.81c3ea","75820a86.88cb34","d71a2d64.96f11","468bed14.371834","966647f4.04d118","dcaf40a0.f5765","a1c3d7d9ed4ca2aa"]]},{"id":"5c5a68688e21615b","type":"link out","z":"2abb1f4f.a17b3","name":"","mode":"link","links":["f52ff4a52e2b1d5a","cc105958f0854c12"],"x":1335,"y":500,"wires":[]},{"id":"f52ff4a52e2b1d5a","type":"link in","z":"2abb1f4f.a17b3","name":"","links":["5c5a68688e21615b"],"x":2645,"y":500,"wires":[["da9539f3.b3d2c8","c38a7edd.8bcd1","ebb23fe5.6f36a","5e158aec.fdaa54","908b864a.c84778","d4ed1e35.11fed","bf205bf6.cea2b8"]]},{"id":"172746cbd4e45bda","type":"comment","z":"2abb1f4f.a17b3","name":"Power Flow Stats","info":"","x":2640,"y":460,"wires":[]},{"id":"febaaff23a5c9206","type":"function","z":"2abb1f4f.a17b3","name":"Battery Information","func":"\nmsg.payload.systemTime=msg.payload['raw']['invertor']['system_time']\n\nreturn msg;\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2910,"y":1540,"wires":[["5ccb5620679a5530"]]},{"id":"5ccb5620679a5530","type":"ha-entity","z":"2abb1f4f.a17b3","name":"System Time","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy System Time"},{"property":"device_class","value":"solar"},{"property":"icon","value":"mdi:solar-panels"},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"payload.systemTime","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":3270,"y":1540,"wires":[["28e5c31dde527883"]]},{"id":"28e5c31dde527883","type":"debug","z":"2abb1f4f.a17b3","name":"systemTime","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":3470,"y":1540,"wires":[]},{"id":"a1c3d7d9ed4ca2aa","type":"ha-entity","z":"2abb1f4f.a17b3","name":"GivEnergy PVI Today kWh","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"GivEnergy PVI Today kWh"},{"property":"device_class","value":"energy"},{"property":"icon","value":"mdi:solar-power"},{"property":"unit_of_measurement","value":"kWh"},{"property":"state_class","value":"total_increasing"},{"property":"last_reset","value":""}],"state":"payload.pvEnergyToday","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1400,"y":2160,"wires":[["7ac3479a1f3ca71b"]]},{"id":"724dd792789e202d","type":"function","z":"2abb1f4f.a17b3","name":"","func":"value = msg.payload.state\nvar fc=16;\nvar sa=11;\nvar addresses=2;\nvar unitid=1;\nvar buf=Buffer.alloc(4);//create buffer\nbuf.writeFloatBE(value);\nvar values=[(buf[0]*256+buf[1]),(buf[2]*256)+buf[3]]\n\nmsg.slave_ip=\"192.168.1.125\";\nmsg.payload={\"value\":values , 'fc': fc, 'unitid': unitid, 'address': sa , 'quantity': addresses };\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1740,"y":300,"wires":[["d93c0f637f7427ad","db8be7e720093fd9"]],"inputLabels":["value"]},{"id":"3d6451c3d2bdbadd","type":"function","z":"2abb1f4f.a17b3","name":"","func":"value = msg.payload.state\nvar fc=16;\nvar sa=1;\nvar addresses=2;\nvar unitid=1;\nvar buf=Buffer.alloc(4);//create buffer\nbuf.writeFloatBE(value);\nvar values=[(buf[0]*256+buf[1]),(buf[2]*256)+buf[3]]\n\nmsg.slave_ip=\"192.168.1.125\";\nmsg.payload={\"value\":values , 'fc': fc, 'unitid': unitid, 'address': sa , 'quantity': addresses };\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1760,"y":600,"wires":[["db8be7e720093fd9"]]},{"id":"d7675146e294c45c","type":"function","z":"2abb1f4f.a17b3","name":"","func":"value = msg.payload.state\nvar fc=16;\nvar sa=5;\nvar addresses=2;\nvar unitid=1;\nvar buf=Buffer.alloc(4);//create buffer\nbuf.writeFloatBE(value);\nvar values=[(buf[0]*256+buf[1]),(buf[2]*256)+buf[3]]\n\nmsg.slave_ip=\"192.168.1.125\";\nmsg.payload={\"value\":values , 'fc': fc, 'unitid': unitid, 'address': sa , 'quantity': addresses };\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1740,"y":420,"wires":[["db8be7e720093fd9"]]},{"id":"08d294e28a4fbca1","type":"function","z":"2abb1f4f.a17b3","name":"","func":"value = msg.payload.state\nvar fc=16;\nvar sa=3;\nvar addresses=2;\nvar unitid=1;\nvar buf=Buffer.alloc(4);//create buffer\nbuf.writeFloatBE(value);\nvar values=[(buf[0]*256+buf[1]),(buf[2]*256)+buf[3]]\n\nmsg.slave_ip=\"192.168.1.125\";\nmsg.payload={\"value\":values , 'fc': fc, 'unitid': unitid, 'address': sa , 'quantity': addresses };\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1740,"y":360,"wires":[["db8be7e720093fd9"]]},{"id":"d93c0f637f7427ad","type":"debug","z":"2abb1f4f.a17b3","name":"Loadpower","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1950,"y":260,"wires":[]},{"id":"6e9f47f246583e6c","type":"function","z":"2abb1f4f.a17b3","name":"","func":"value = msg.payload.state\nvar fc=16;\nvar sa=7;\nvar addresses=2;\nvar unitid=1;\nvar buf=Buffer.alloc(4);//create buffer\nbuf.writeFloatBE(value);\nvar values=[(buf[0]*256+buf[1]),(buf[2]*256)+buf[3]]\n\nmsg.slave_ip=\"192.168.1.125\";\nmsg.payload={\"value\":values , 'fc': fc, 'unitid': unitid, 'address': sa , 'quantity': addresses };\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1740,"y":480,"wires":[["db8be7e720093fd9"]]},{"id":"b752e89e7d096e50","type":"function","z":"2abb1f4f.a17b3","name":"","func":"value = msg.payload.state\nvar fc=16;\nvar sa=9;\nvar addresses=2;\nvar unitid=1;\nvar buf=Buffer.alloc(4);//create buffer\nbuf.writeFloatBE(value);\nvar values=[(buf[0]*256+buf[1]),(buf[2]*256)+buf[3]]\n\nmsg.slave_ip=\"192.168.1.125\";\nmsg.payload={\"value\":values , 'fc': fc, 'unitid': unitid, 'address': sa , 'quantity': addresses };\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1740,"y":540,"wires":[["db8be7e720093fd9"]]},{"id":"93025cc820aa7c6d","type":"function","z":"2abb1f4f.a17b3","name":"","func":"value = msg.payload.state\nvar fc=16;\nvar sa=13;\nvar addresses=2;\nvar unitid=1;\nvar buf=Buffer.alloc(4);//create buffer\nbuf.writeFloatBE(value);\nvar values=[(buf[0]*256+buf[1]),(buf[2]*256)+buf[3]]\n\nmsg.slave_ip=\"192.168.1.125\";\nmsg.payload={\"value\":values , 'fc': fc, 'unitid': unitid, 'address': sa , 'quantity': addresses };\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1760,"y":660,"wires":[["db8be7e720093fd9"]]},{"id":"b0e5e659ebefa976","type":"function","z":"2abb1f4f.a17b3","name":"","func":"value = msg.payload.state\nvar fc=16;\nvar sa=15;\nvar addresses=2;\nvar unitid=1;\nvar buf=Buffer.alloc(4);//create buffer\nbuf.writeFloatBE(value);\nvar values=[(buf[0]*256+buf[1]),(buf[2]*256)+buf[3]]\n\nmsg.slave_ip=\"192.168.1.125\";\nmsg.payload={\"value\":values , 'fc': fc, 'unitid': unitid, 'address': sa , 'quantity': addresses };\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1760,"y":720,"wires":[["db8be7e720093fd9"]]},{"id":"db8be7e720093fd9","type":"modbus-flex-write","z":"2abb1f4f.a17b3","name":"","showStatusActivities":false,"showErrors":false,"server":"497973134031428f","emptyMsgOnFail":false,"keepMsgProperties":false,"x":2030,"y":480,"wires":[[],["9591d9ee7f7da220"]]},{"id":"9591d9ee7f7da220","type":"debug","z":"2abb1f4f.a17b3","name":"Modbus","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2180,"y":400,"wires":[]},{"id":"7ac3479a1f3ca71b","type":"link out","z":"2abb1f4f.a17b3","name":"","mode":"link","links":["a8aae8846078141d"],"x":1555,"y":2160,"wires":[]},{"id":"ddeaf50b22f9e750","type":"function","z":"2abb1f4f.a17b3","name":"","func":"value = msg.payload.state\nvar fc=16;\nvar sa=17;\nvar addresses=2;\nvar unitid=1;\nvar buf=Buffer.alloc(4);//create buffer\nbuf.writeFloatBE(value);\nvar values=[(buf[0]*256+buf[1]),(buf[2]*256)+buf[3]]\n\nmsg.slave_ip=\"192.168.1.125\";\nmsg.payload={\"value\":values , 'fc': fc, 'unitid': unitid, 'address': sa , 'quantity': addresses };\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1760,"y":760,"wires":[["db8be7e720093fd9"]]},{"id":"a8aae8846078141d","type":"link in","z":"2abb1f4f.a17b3","name":"","links":["7ac3479a1f3ca71b"],"x":1665,"y":760,"wires":[["ddeaf50b22f9e750"]]},{"id":"7f6d204a21276349","type":"modbus-read","z":"2abb1f4f.a17b3","name":"HWS Temp","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"1","dataType":"HoldingRegister","adr":"21","quantity":"2","rate":"15","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"497973134031428f","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":2170,"y":580,"wires":[[],["fc1aa1c4975fc1ea"]]},{"id":"b678d451f298d8a7","type":"debug","z":"2abb1f4f.a17b3","name":"Modbus Read","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2520,"y":560,"wires":[]},{"id":"fc1aa1c4975fc1ea","type":"function","z":"2abb1f4f.a17b3","name":"","func":"const buf = Buffer.from(msg.payload.buffer);\nconst value = buf.readFloatBE();\nmsg.payload = value.toFixed(2);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2360,"y":620,"wires":[["b678d451f298d8a7","864e195d78fa2cb0"]]},{"id":"864e195d78fa2cb0","type":"ha-entity","z":"2abb1f4f.a17b3","name":"HWS Temperature","server":"e9933ddd.73d49","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"HWS Temperature"},{"property":"device_class","value":"temperature"},{"property":"icon","value":"mdi:thermometer"},{"property":"unit_of_measurement","value":"°C"},{"property":"state_class","value":"measurement"},{"property":"last_reset","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"","outputPayloadType":"str","x":2530,"y":660,"wires":[[]]},{"id":"e9933ddd.73d49","type":"server","name":"Home Assistant","version":4,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m"},{"id":"5b965f44.9c103","type":"persist-store","filename":"givenergy_persistence.json","interval":"60"},{"id":"f881843250fc6031","type":"influxdb","hostname":"127.0.0.1","port":"8086","protocol":"http","database":"database","name":"homeassistant","usetls":false,"tls":"","influxdbVersion":"1.8-flux","url":"http://localhost:8086","rejectUnauthorized":false},{"id":"497973134031428f","type":"modbus-client","name":"","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"192.168.1.125","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","serialAsciiResponseStartDelimiter":"0x3A","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true}]