Skip to content

Instantly share code, notes, and snippets.

@GwelforBodad
Last active July 25, 2022 07:37
Show Gist options
  • Save GwelforBodad/6137c3e826309670794f73e720e6938a to your computer and use it in GitHub Desktop.
Save GwelforBodad/6137c3e826309670794f73e720e6938a to your computer and use it in GitHub Desktop.
Givenergy Plants and Inverter API (v1)

For Givenergy Customers who have a web account, this collection of nodes uses your API Key to access your Plant(s) (inverter(s) and batteries). To access the API Key, you need to go to beta.givenergy.cloud (until the url is updated to www.givenergy.cloud) and log in with your account userid and password. Go to Account Details. At the bootm, click on the button next to the Givenergy API Key to generate your key. This will be emailed to you and will not change as long as you don't need it to. COpy and paste this key into the Inject Node of the flow below titled "Initailise flow contexts - Put your API Key into here". The key needs to replace the text Key?

Once this is done and the flow deployed, a number of flow varaibles will be set and you can pull back the data from the relevant APIs to the debug node. Once you're doing that, you're free to use the data as you will.

This flow is set up for two inverters, each having one battery, but it can be changed to work with just one inverter or several batteries per inverter - it's a starter for you to work with.

The main purpose of this contrib is to illustrate how the Givenergy API authorisation and required parameters can be built into a Node-RED HTTP request successfully.

[{"id":"a410cd30d9a81aed","type":"tab","label":"Givenergy APIv1","disabled":false,"info":""},{"id":"566b4c1ee047fb9f","type":"debug","z":"a410cd30d9a81aed","name":"POST Request Debug","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":920,"y":760,"wires":[]},{"id":"ae2e1ba668c358e9","type":"inject","z":"a410cd30d9a81aed","name":"Initailise flow contexts - Put your API Key into here","props":[{"p":"payload"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"Key?","payloadType":"str","x":230,"y":80,"wires":[["8a2dabe94c62b4f5"]]},{"id":"8a2dabe94c62b4f5","type":"function","z":"a410cd30d9a81aed","name":"Set Flow Context and Get Your Communication Devices","func":"flow.set (\"BaseURL\", \"https://api.givenergy.cloud/v1/\")\nvar headersobject = {}\nheadersobject[\"Authorization\"] = \"Bearer \" + msg.payload\nheadersobject[\"Content-Type\"] = \"application/json\"\nheadersobject[\"Accept\"] = \"application/json\"\nflow.set (\"msgheaders\", headersobject)\nmsg.headers = flow.get(\"msgheaders\")\nmsg.api = \"communication-device\" // Also used later to route message\nmsg.url = flow.get(\"BaseURL\") + msg.api\nmsg.payload = \"\"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":690,"y":80,"wires":[["751965fd98d44951"]]},{"id":"bb02d0d696cf7460","type":"http request","z":"a410cd30d9a81aed","name":"GET Request","method":"GET","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":640,"y":660,"wires":[["566b4c1ee047fb9f","fb8716ff1165201e"]]},{"id":"8d84a01098a8acf3","type":"function","z":"a410cd30d9a81aed","name":"Set Serial Numbers","func":"flow.set(\"inverterCount\", msg.payload.data.length)\nflow.set (\"CommDongleSN0\", msg.payload.data[0].serial_number)\nflow.set (\"InverterSN0\", msg.payload.data[0].inverter.serial)\nflow.set (\"BatterySN0\", msg.payload.data[0].inverter.connections.batteries[0].serial)\nflow.set (\"batteryCount0\", msg.payload.data[0].inverter.connections.batteries.length)\nif (flow.get(\"batteryCount0\") > 1) {\n flow.set (\"BatterySN01\", msg.payload.data[0].inverter.connections.batteries[1].serial)\n }\nif (flow.get(\"inverterCount\") > 1) {\n flow.set (\"CommDongleSN1\", msg.payload.data[1].serial_number)\n flow.set (\"InverterSN1\", msg.payload.data[1].inverter.serial)\n flow.set (\"BatterySN1\", msg.payload.data[1].inverter.connections.batteries[0].serial)\n flow.set (\"batteryCount1\", msg.payload.data[1].inverter.connections.batteries.length)\n if (flow.get(\"batteryCount1\") > 1) {\n flow.set (\"BatterySN11\", msg.payload.data[1].inverter.connections.batteries[1].serial)\n }\n}\nif (flow.get(\"inverterCount\") > 2) {\n flow.set (\"CommDongleSN2\", msg.payload.data[2].serial_number)\n flow.set (\"InverterSN2\", msg.payload.data[2].inverter.serial)\n flow.set (\"BatterySN2\", msg.payload.data[2].inverter.connections.batteries[0].serial)\n flow.set (\"batteryCount2\", msg.payload.data[2].inverter.connections.batteries.length)\n if (flow.get(\"batteryCount2\") > 1) {\n flow.set (\"BatterySN21\", msg.payload.data[2].inverter.connections.batteries[1].serial)\n }\n}\n// Add additional lines to code if there are additional inverters\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":830,"y":140,"wires":[["c308bb2f37cce6a3","0ec9230ea0731c4a","8a42e5a39fe67301","fa86ef60a10b6ce4","fe3359acd026e9f4","6907a119b23e4742","61fe3e426904d389","80bbadacfdc21453","e43e3e9e86232f96","6409fc6a812a4da1"]]},{"id":"1cf9c154cff4b540","type":"comment","z":"a410cd30d9a81aed","name":"Initialisation requires Givenergy Auth-key from web account added to Get session cookies function","info":"","x":360,"y":40,"wires":[]},{"id":"ce8602dd6514fef6","type":"inject","z":"a410cd30d9a81aed","name":"GetLatestSystemData","props":[{"p":"api","v":"Inverter","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"str","x":140,"y":500,"wires":[["adedcb656ede7931"]]},{"id":"adedcb656ede7931","type":"function","z":"a410cd30d9a81aed","name":"Set Cookies and URL","func":"msg.headers = flow.get(\"msgheaders\")\nmsg.url = {}\nif (msg.api == \"Inverter\")\n{\n msg.api = \"/system-data/latest\"\n}\nelse if (msg.api == \"Meter\")\n{\n msg.api = \"/meter-data/latest\"\n}\n// else if (msg.api == \"BatCellData\")\n// {\n// msg.api = \"pcs/batCell/getBatCellData?serialNum=\"\n// }\nmsg.inverter = flow.get(\"InverterSN0\") // msg.inverter used later to route output\nmsg.url = flow.get(\"BaseURL\") + \"inverter/\" + msg.inverter + msg.api\nnode.send(msg)\nmsg.inverter = flow.get(\"InverterSN1\")\nmsg.url = flow.get(\"BaseURL\") + \"inverter/\" + msg.inverter + msg.api\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":420,"y":540,"wires":[["bb02d0d696cf7460"]]},{"id":"758a310fc792d225","type":"inject","z":"a410cd30d9a81aed","name":"GetLatestMeterData","props":[{"p":"api","v":"Meter","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":130,"y":540,"wires":[["adedcb656ede7931"]]},{"id":"751965fd98d44951","type":"http request","z":"a410cd30d9a81aed","name":"Get Communication Devices","method":"GET","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":560,"y":140,"wires":[["8d84a01098a8acf3"]]},{"id":"ec189ff0602f5bdd","type":"comment","z":"a410cd30d9a81aed","name":"Inverter Control","info":"(Register) Function\n(83)\tRestart\n(26)\tBattery SoC Calibration\nEnable/Disable\n\t(24)\tEnable ECO Mode\n\t(17)\tEnable AC Charge Upper % Limit\n\t(77)\tAC Charge Upper Limit 4% to ?\n\t(56)\tEnable DC Discharge\n\t(66)\tEnable AC Charge\nCharge 1 Settings\n\t(64)\tAC Charge 1 Start Time\n\t(65)\tAC Charge 1 End Time\nDischarge 1 Settings\n\t(53)\tDC Discharge 1 Start Time\n\t(54)\tDC Discharge 1 End Time\nCharge 2 Settings\n\t(28)\tAC Charge 2 Start Time\n\t(29)\tAC Charge 2 End Time\nDischarge 2 Settings\n\t(41)\tDC Discharge 2 Start Time\n\t(42)\tDC Discharge 2 End Time\nPercentage Limits\n\t(71)\tBattery Reserve % Limit\t4% to ?\n\t(72)\tBattery Charge Power\t? to 2600W\n\t(73)\tBattery Discharge Power \t? to 2600W\n\t(75)\tBattery cutoff % Limit\t4% to ?\nTime & Date \n\tSet Date and Time\nControl\n\t(47)\tInverter Max Output Active Power Percent \t? to 100%","x":120,"y":600,"wires":[]},{"id":"e148fcff3cea910f","type":"function","z":"a410cd30d9a81aed","name":"Set Cookies and URL","func":"msg.headers = flow.get(\"msgheaders\")\nmsg.url = {}\n// if (msg.api == \"Inverter\")\n// {\n// msg.api = \"/system-data/latest\"\n// }\n// else if (msg.api == \"Meter\")\n// {\n// msg.api = \"/meter-data/latest\"\n// }\n// else if (msg.api == \"BatCellData\")\n// {\n// msg.api = \"pcs/batCell/getBatCellData?serialNum=\"\n// }\nmsg.url = flow.get(\"BaseURL\") + \"inverter/\" + flow.get(\"InverterSN0\") + msg.api\nnode.send(msg)\n// msg.url = flow.get(\"BaseURL\") + msg.api + flow.get(\"InverterSN1\")\nmsg.url = flow.get(\"BaseURL\") + \"inverter/\" + flow.get(\"InverterSN1\") + msg.api\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":380,"y":640,"wires":[["bb02d0d696cf7460"]]},{"id":"b3bf39edb19c0cc7","type":"inject","z":"a410cd30d9a81aed","name":"GET Setting Presets","props":[{"p":"api","v":"/presets","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":130,"y":640,"wires":[["e148fcff3cea910f"]]},{"id":"cf9c3d93365959d6","type":"inject","z":"a410cd30d9a81aed","name":"Read Inverter Settings","props":[{"p":"api","v":"/presets/","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":140,"y":700,"wires":[["fdc28b6413119f12"]]},{"id":"8a42e5a39fe67301","type":"ui_text","z":"a410cd30d9a81aed","group":"cb369baad6ddbb8d","order":3,"width":0,"height":0,"name":"Inverter 1 Model","label":"Inverter Model","format":"{{msg.payload.data[0].inverter.info.model}}","layout":"row-spread","className":"","x":1200,"y":100,"wires":[]},{"id":"0ec9230ea0731c4a","type":"ui_text","z":"a410cd30d9a81aed","group":"cb369baad6ddbb8d","order":2,"width":0,"height":0,"name":"Inverter 1 Serial Number ","label":"Inverter Serial Number","format":"{{msg.payload.data[0].inverter.serial}}","layout":"row-spread","className":"","x":1230,"y":60,"wires":[]},{"id":"c308bb2f37cce6a3","type":"ui_text","z":"a410cd30d9a81aed","group":"cb369baad6ddbb8d","order":1,"width":0,"height":0,"name":"Inverter 1 Dongle","label":"Inverter Dongle","format":"{{msg.payload.data[0].serial_number}}","layout":"row-spread","className":"","x":1210,"y":20,"wires":[]},{"id":"fa86ef60a10b6ce4","type":"ui_text","z":"a410cd30d9a81aed","group":"cb369baad6ddbb8d","order":6,"width":0,"height":0,"name":"Battery 1 Serial Number","label":"Battery Serial Number","format":"{{msg.payload.data[0].inverter.connections.batteries[0].serial}}","layout":"row-spread","className":"","x":1230,"y":220,"wires":[]},{"id":"fe3359acd026e9f4","type":"ui_text","z":"a410cd30d9a81aed","group":"cb369baad6ddbb8d","order":7,"width":0,"height":0,"name":"Battery 1 Design Capacity","label":"Battery Design Capacity (A)","format":"{{msg.payload.data[0].inverter.connections.batteries[0].capacity.design}}","layout":"row-spread","className":"","x":1230,"y":260,"wires":[]},{"id":"e170bdbb09781e8b","type":"ui_text","z":"a410cd30d9a81aed","group":"cb369baad6ddbb8d","order":4,"width":0,"height":0,"name":"PV Array 1 Output","label":"PV Array Output (W)","format":"{{msg.payload.data.solar.power}}","layout":"row-spread","className":"","x":1210,"y":140,"wires":[]},{"id":"aee751d924ce7dbd","type":"ui_text","z":"a410cd30d9a81aed","group":"cb369baad6ddbb8d","order":8,"width":0,"height":0,"name":"Battery 1 Charge","label":"Battery Charge (%)","format":"{{msg.payload.data.battery.percent}}","layout":"row-spread","className":"","x":1210,"y":300,"wires":[]},{"id":"0a24b03c71101fee","type":"ui_text","z":"a410cd30d9a81aed","group":"cb369baad6ddbb8d","order":5,"width":0,"height":0,"name":"Inverter 1 Output","label":"Inverter Output (W)","format":"{{msg.payload.data.inverter.power}}","layout":"row-spread","className":"","x":1210,"y":180,"wires":[]},{"id":"c30a6d1c2d1cde40","type":"debug","z":"a410cd30d9a81aed","name":"Inverter0","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":740,"y":1160,"wires":[]},{"id":"f09734627beaf11d","type":"debug","z":"a410cd30d9a81aed","name":"Inverter1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":740,"y":1200,"wires":[]},{"id":"25a1ca6f35f6f4b3","type":"comment","z":"a410cd30d9a81aed","name":"Update with latest data","info":"","x":140,"y":460,"wires":[]},{"id":"a9755fb05c4ce65f","type":"ui_text","z":"a410cd30d9a81aed","group":"485e9efdd8b5de83","order":1,"width":0,"height":0,"name":"Battery 1 SoC Calibration","label":"Battery SoC Calibration","format":"{{msg.payload.data.value}}","layout":"row-spread","className":"","x":1190,"y":820,"wires":[]},{"id":"fdc28b6413119f12","type":"function","z":"a410cd30d9a81aed","name":"Set Cookies and URL","func":"var regArray = [26, 24, 17, 77, 56, 66, 64, 65, 53, 54, 28, 29, 41, 42, 71, 72, 73, 75, 47]\nmsg.headers = flow.get(\"msgheaders\")\nmsg.inverter = flow.get(\"InverterSN0\") // msg.inverter used later to route output\nfor (var i = 0; i < regArray.length; i++) {\n msg.register = regArray[i]\n msg.url = {}\n msg.url = flow.get(\"BaseURL\") + \"inverter/\" + msg.inverter + \"/settings/\" + msg.register + \"/read\"\n node.send(msg)\n }\nmsg.inverter = flow.get(\"InverterSN1\") // msg.inverter used later to route output\nfor (i = 0; i < regArray.length; i++) {\n msg.register = regArray[i]\n msg.url = {}\n msg.url = flow.get(\"BaseURL\") + \"inverter/\" + msg.inverter + \"/settings/\" + msg.register + \"/read\"\n node.send(msg)\n }\nreturn null;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":700,"wires":[["74566f2975015911"]]},{"id":"27999dd450263231","type":"function","z":"a410cd30d9a81aed","name":"Route Inverter Read","func":"if (msg.inverter == flow.get(\"InverterSN0\")) {\n return [ msg, null ]\n}\nelse if (msg.inverter == flow.get(\"InverterSN1\")) {\n return [ null, msg ]\n}\nelse return [ null, null ]","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":1200,"wires":[["edd19bcf59b74509","c30a6d1c2d1cde40"],["f09734627beaf11d","6d62fb8e19b31e67"]],"outputLabels":["Inverter1","Inverter2"]},{"id":"e56194c1b42555c7","type":"http request","z":"a410cd30d9a81aed","name":"POST Request","method":"POST","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":360,"y":780,"wires":[["27999dd450263231"]]},{"id":"fb8716ff1165201e","type":"function","z":"a410cd30d9a81aed","name":"Route Inverter Data","func":"if (msg.inverter == flow.get(\"InverterSN0\")) {\n return [ msg, null ]\n}\nelse if (msg.inverter == flow.get(\"InverterSN1\")) {\n return [ null, msg ]\n}\nelse return [ null, null ]","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":410,"y":400,"wires":[["19814019c24a74d0"],["f1fedd96f366aa9b"]],"outputLabels":["Inverter0","Inverter1"]},{"id":"edd19bcf59b74509","type":"switch","z":"a410cd30d9a81aed","name":"Inverter0 Values","property":"register","propertyType":"msg","rules":[{"t":"eq","v":"26","vt":"num"},{"t":"eq","v":"24","vt":"num"},{"t":"eq","v":"17","vt":"num"},{"t":"eq","v":"77","vt":"num"},{"t":"eq","v":"56","vt":"num"},{"t":"eq","v":"66","vt":"num"},{"t":"eq","v":"71","vt":"num"},{"t":"eq","v":"72","vt":"num"},{"t":"eq","v":"73","vt":"num"},{"t":"eq","v":"75","vt":"num"},{"t":"eq","v":"47","vt":"num"}],"checkall":"true","repair":false,"outputs":11,"x":750,"y":940,"wires":[["a9755fb05c4ce65f"],["5f677909bc42b7ad"],["31b955180923ee74"],["89f3ed68b7b011b8"],["0ae183dcbbfe91d6"],["83fcbff4adb2e2d6"],["6ebc99486bac9875"],["ecc1eb73d906c40a"],["df9939ba75d0aaa8"],["31c3d90f5f33cab1"],["43f2dc06dcef2942"]],"outputLabels":["(26)\tBattery SoC Calibration","(24)\tEnable ECO Mode","(17)\tEnable AC Charge Upper % Limit","(77)\tAC Charge Upper Limit 4% to ?","(56)\tEnable DC Discharge","(66)\tEnable AC Charge","(71)\tBattery Reserve % Limit","(72)\tBattery Charge Power","(73)\tBattery Discharge Power","(75)\tBattery cutoff % Limit","(47)\tInverter Max Output Active Power %"]},{"id":"5f677909bc42b7ad","type":"ui_text","z":"a410cd30d9a81aed","group":"485e9efdd8b5de83","order":2,"width":0,"height":0,"name":"Enable ECO Mode","label":"Enable ECO Mode","format":"{{msg.payload.data.value}}","layout":"row-spread","className":"","x":1170,"y":860,"wires":[]},{"id":"31b955180923ee74","type":"ui_text","z":"a410cd30d9a81aed","group":"485e9efdd8b5de83","order":3,"width":0,"height":0,"name":"Enable AC Charge Upper % Limit","label":"Enable AC Charge Upper % Limit","format":"{{msg.payload.data.value}}","layout":"row-spread","className":"","x":1220,"y":900,"wires":[]},{"id":"89f3ed68b7b011b8","type":"ui_text","z":"a410cd30d9a81aed","group":"485e9efdd8b5de83","order":4,"width":0,"height":0,"name":"AC Charge Upper Limit","label":"AC Charge Upper Limit (%)","format":"{{msg.payload.data.value}}","layout":"row-spread","className":"","x":1190,"y":940,"wires":[]},{"id":"0ae183dcbbfe91d6","type":"ui_text","z":"a410cd30d9a81aed","group":"485e9efdd8b5de83","order":5,"width":0,"height":0,"name":"Enable DC Discharge","label":"Enable DC Discharge","format":"{{msg.payload.data.value}}","layout":"row-spread","className":"","x":1180,"y":980,"wires":[]},{"id":"83fcbff4adb2e2d6","type":"ui_text","z":"a410cd30d9a81aed","group":"485e9efdd8b5de83","order":6,"width":0,"height":0,"name":"Enable AC Charge","label":"Enable AC Charge","format":"{{msg.payload.data.value}}","layout":"row-spread","className":"","x":1170,"y":1020,"wires":[]},{"id":"6ebc99486bac9875","type":"ui_text","z":"a410cd30d9a81aed","group":"485e9efdd8b5de83","order":7,"width":0,"height":0,"name":"Battery Reserve Limit","label":"Battery Reserve Limit (%)","format":"{{msg.payload.data.value}}","layout":"row-spread","className":"","x":1180,"y":1060,"wires":[]},{"id":"ecc1eb73d906c40a","type":"ui_text","z":"a410cd30d9a81aed","group":"485e9efdd8b5de83","order":8,"width":0,"height":0,"name":"Battery Charge Power","label":"Battery Charge Power (W)","format":"{{msg.payload.data.value}}","layout":"row-spread","className":"","x":1180,"y":1100,"wires":[]},{"id":"df9939ba75d0aaa8","type":"ui_text","z":"a410cd30d9a81aed","group":"485e9efdd8b5de83","order":9,"width":0,"height":0,"name":"Battery Discharge Power","label":"Battery Discharge Power (W)","format":"{{msg.payload.data.value}}","layout":"row-spread","className":"","x":1190,"y":1140,"wires":[]},{"id":"31c3d90f5f33cab1","type":"ui_text","z":"a410cd30d9a81aed","group":"485e9efdd8b5de83","order":10,"width":0,"height":0,"name":"Battery cutoff Limit","label":"Battery cutoff Limit (%)","format":"{{msg.payload.data.value}}","layout":"row-spread","className":"","x":1170,"y":1180,"wires":[]},{"id":"43f2dc06dcef2942","type":"ui_text","z":"a410cd30d9a81aed","group":"485e9efdd8b5de83","order":11,"width":0,"height":0,"name":"Inverter Max Output Active Power","label":"Inverter Max Output Active Power (%)","format":"{{msg.payload.data.value}}","layout":"row-spread","className":"","x":1220,"y":1220,"wires":[]},{"id":"74566f2975015911","type":"delay","z":"a410cd30d9a81aed","name":"Slow message stream","pauseType":"rate","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"x":620,"y":700,"wires":[["e56194c1b42555c7"]]},{"id":"19814019c24a74d0","type":"function","z":"a410cd30d9a81aed","name":"Route Latest Data","func":"if (msg.api == \"/system-data/latest\") {\n return [ msg, null ]\n}\nelse if (msg.api == \"/meter-data/latest\") {\n return [ null, msg ]\n}\nelse return [ null, null ]","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":710,"y":340,"wires":[["e170bdbb09781e8b","0a24b03c71101fee","aee751d924ce7dbd"],["474d94c0b9789b3f","d865935eb2ec2cee","a754533f23b5dcca"]],"outputLabels":["System","Meter"]},{"id":"474d94c0b9789b3f","type":"ui_text","z":"a410cd30d9a81aed","group":"b9377b738186821b","order":1,"width":0,"height":0,"name":"Grid Import Today","label":"Grid Import Today (kWh)","format":"{{msg.payload.data.today.grid.import}}","layout":"row-spread","className":"","x":1210,"y":700,"wires":[]},{"id":"a754533f23b5dcca","type":"ui_text","z":"a410cd30d9a81aed","group":"b9377b738186821b","order":2,"width":0,"height":0,"name":"Grid Export Today","label":"Grid Export Today (kWh)","format":"{{msg.payload.data.today.grid.export}}","layout":"row-spread","className":"","x":1210,"y":740,"wires":[]},{"id":"d865935eb2ec2cee","type":"ui_text","z":"a410cd30d9a81aed","group":"b9377b738186821b","order":3,"width":0,"height":0,"name":"Solar Generation Today","label":"Solar Generation Today (kWh)","format":"{{msg.payload.data.today.solar}}","layout":"row-spread","className":"","x":1230,"y":660,"wires":[]},{"id":"f83f1a5a2bb9780a","type":"ui_text","z":"a410cd30d9a81aed","group":"830ea27574d20824","order":1,"width":0,"height":0,"name":"Battery 2 SoC Calibration","label":"Battery SoC Calibration","format":"{{msg.payload.data.value}}","layout":"row-spread","className":"","x":1190,"y":1260,"wires":[]},{"id":"6d62fb8e19b31e67","type":"switch","z":"a410cd30d9a81aed","name":"Inverter1 Values","property":"register","propertyType":"msg","rules":[{"t":"eq","v":"26","vt":"num"},{"t":"eq","v":"24","vt":"num"},{"t":"eq","v":"17","vt":"num"},{"t":"eq","v":"77","vt":"num"},{"t":"eq","v":"56","vt":"num"},{"t":"eq","v":"66","vt":"num"},{"t":"eq","v":"71","vt":"num"},{"t":"eq","v":"72","vt":"num"},{"t":"eq","v":"73","vt":"num"},{"t":"eq","v":"75","vt":"num"},{"t":"eq","v":"47","vt":"num"}],"checkall":"true","repair":false,"outputs":11,"x":750,"y":1380,"wires":[["f83f1a5a2bb9780a"],["2d37135d9130055e"],["43d888952e6342f8"],["8fbc58bf4ab45ad3"],["ec7e4849669befa0"],["19d84dc34f3a5770"],["4c0df4e668a7bc5d"],["39f935903b3ec888"],["65675673b6cd1e5d"],["f3acc0dbc735de2b"],["d44075a518433bb8"]],"outputLabels":["(26)\tBattery SoC Calibration","(24)\tEnable ECO Mode","(17)\tEnable AC Charge Upper % Limit","(77)\tAC Charge Upper Limit 4% to ?","(56)\tEnable DC Discharge","(66)\tEnable AC Charge","(71)\tBattery Reserve % Limit","(72)\tBattery Charge Power","(73)\tBattery Discharge Power","(75)\tBattery cutoff % Limit","(47)\tInverter Max Output Active Power %"]},{"id":"2d37135d9130055e","type":"ui_text","z":"a410cd30d9a81aed","group":"830ea27574d20824","order":2,"width":0,"height":0,"name":"Enable ECO Mode","label":"Enable ECO Mode","format":"{{msg.payload.data.value}}","layout":"row-spread","className":"","x":1170,"y":1300,"wires":[]},{"id":"43d888952e6342f8","type":"ui_text","z":"a410cd30d9a81aed","group":"830ea27574d20824","order":3,"width":0,"height":0,"name":"Enable AC Charge Upper % Limit","label":"Enable AC Charge Upper % Limit","format":"{{msg.payload.data.value}}","layout":"row-spread","className":"","x":1220,"y":1340,"wires":[]},{"id":"8fbc58bf4ab45ad3","type":"ui_text","z":"a410cd30d9a81aed","group":"830ea27574d20824","order":4,"width":0,"height":0,"name":"AC Charge Upper Limit","label":"AC Charge Upper Limit (%)","format":"{{msg.payload.data.value}}","layout":"row-spread","className":"","x":1190,"y":1380,"wires":[]},{"id":"ec7e4849669befa0","type":"ui_text","z":"a410cd30d9a81aed","group":"830ea27574d20824","order":5,"width":0,"height":0,"name":"Enable DC Discharge","label":"Enable DC Discharge","format":"{{msg.payload.data.value}}","layout":"row-spread","className":"","x":1180,"y":1420,"wires":[]},{"id":"19d84dc34f3a5770","type":"ui_text","z":"a410cd30d9a81aed","group":"830ea27574d20824","order":6,"width":0,"height":0,"name":"Enable AC Charge","label":"Enable AC Charge","format":"{{msg.payload.data.value}}","layout":"row-spread","className":"","x":1170,"y":1460,"wires":[]},{"id":"4c0df4e668a7bc5d","type":"ui_text","z":"a410cd30d9a81aed","group":"830ea27574d20824","order":7,"width":0,"height":0,"name":"Battery Reserve Limit","label":"Battery Reserve Limit (%)","format":"{{msg.payload.data.value}}","layout":"row-spread","className":"","x":1180,"y":1500,"wires":[]},{"id":"39f935903b3ec888","type":"ui_text","z":"a410cd30d9a81aed","group":"830ea27574d20824","order":8,"width":0,"height":0,"name":"Battery Charge Power","label":"Battery Charge Power (W)","format":"{{msg.payload.data.value}}","layout":"row-spread","className":"","x":1180,"y":1540,"wires":[]},{"id":"65675673b6cd1e5d","type":"ui_text","z":"a410cd30d9a81aed","group":"830ea27574d20824","order":9,"width":0,"height":0,"name":"Battery Discharge Power","label":"Battery Discharge Power (W)","format":"{{msg.payload.data.value}}","layout":"row-spread","className":"","x":1190,"y":1580,"wires":[]},{"id":"f3acc0dbc735de2b","type":"ui_text","z":"a410cd30d9a81aed","group":"830ea27574d20824","order":10,"width":0,"height":0,"name":"Battery cutoff Limit","label":"Battery cutoff Limit (%)","format":"{{msg.payload.data.value}}","layout":"row-spread","className":"","x":1170,"y":1620,"wires":[]},{"id":"d44075a518433bb8","type":"ui_text","z":"a410cd30d9a81aed","group":"830ea27574d20824","order":11,"width":0,"height":0,"name":"Inverter Max Output Active Power","label":"Inverter Max Output Active Power (%)","format":"{{msg.payload.data.value}}","layout":"row-spread","className":"","x":1220,"y":1660,"wires":[]},{"id":"80bbadacfdc21453","type":"ui_text","z":"a410cd30d9a81aed","group":"afda8f86d6366faf","order":3,"width":0,"height":0,"name":"Inverter 2 Model","label":"Inverter Model","format":"{{msg.payload.data[1].inverter.info.model}}","layout":"row-spread","className":"","x":1200,"y":420,"wires":[]},{"id":"61fe3e426904d389","type":"ui_text","z":"a410cd30d9a81aed","group":"afda8f86d6366faf","order":2,"width":0,"height":0,"name":"Inverter 2 Serial Number ","label":"Inverter Serial Number","format":"{{msg.payload.data[1].inverter.serial}}","layout":"row-spread","className":"","x":1230,"y":380,"wires":[]},{"id":"6907a119b23e4742","type":"ui_text","z":"a410cd30d9a81aed","group":"afda8f86d6366faf","order":1,"width":0,"height":0,"name":"Inverter 2 Dongle","label":"Inverter Dongle","format":"{{msg.payload.data[1].serial_number}}","layout":"row-spread","className":"","x":1210,"y":340,"wires":[]},{"id":"e43e3e9e86232f96","type":"ui_text","z":"a410cd30d9a81aed","group":"afda8f86d6366faf","order":6,"width":0,"height":0,"name":"Battery 2 Serial Number","label":"Battery Serial Number","format":"{{msg.payload.data[1].inverter.connections.batteries[0].serial}}","layout":"row-spread","className":"","x":1230,"y":540,"wires":[]},{"id":"6409fc6a812a4da1","type":"ui_text","z":"a410cd30d9a81aed","group":"afda8f86d6366faf","order":7,"width":0,"height":0,"name":"Battery 2 Design Capacity","label":"Battery Design Capacity (A)","format":"{{msg.payload.data[1].inverter.connections.batteries[0].capacity.design}}","layout":"row-spread","className":"","x":1230,"y":580,"wires":[]},{"id":"a6ef0159b660bf6e","type":"ui_text","z":"a410cd30d9a81aed","group":"afda8f86d6366faf","order":4,"width":0,"height":0,"name":"PV Array 2 Output","label":"PV Array Output (W)","format":"{{msg.payload.data.solar.power}}","layout":"row-spread","className":"","x":1210,"y":460,"wires":[]},{"id":"9ebf8fb20a4fbc49","type":"ui_text","z":"a410cd30d9a81aed","group":"afda8f86d6366faf","order":8,"width":0,"height":0,"name":"Battery 2 Charge","label":"Battery Charge (%)","format":"{{msg.payload.data.battery.percent}}","layout":"row-spread","className":"","x":1210,"y":620,"wires":[]},{"id":"f8a2304b832b8e43","type":"ui_text","z":"a410cd30d9a81aed","group":"afda8f86d6366faf","order":5,"width":0,"height":0,"name":"Inverter 2 Output","label":"Inverter Output (W)","format":"{{msg.payload.data.inverter.power}}","layout":"row-spread","className":"","x":1210,"y":500,"wires":[]},{"id":"f1fedd96f366aa9b","type":"function","z":"a410cd30d9a81aed","name":"Route Latest Data","func":"if (msg.api == \"/system-data/latest\") {\n return [ msg, null ]\n}\nelse if (msg.api == \"/meter-data/latest\") {\n return [ null, msg ]\n}\nelse return [ null, null ]","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":730,"y":520,"wires":[["a6ef0159b660bf6e","f8a2304b832b8e43","9ebf8fb20a4fbc49"],["d865935eb2ec2cee","474d94c0b9789b3f","a754533f23b5dcca"]],"outputLabels":["System","Meter"]},{"id":"cb369baad6ddbb8d","type":"ui_group","name":"Readings Inverter 1","tab":"09d570a98f2d7086","order":2,"disp":true,"width":"6","collapse":false,"className":""},{"id":"485e9efdd8b5de83","type":"ui_group","name":"Parameters Inverter 1","tab":"09d570a98f2d7086","order":3,"disp":true,"width":"6","collapse":false,"className":""},{"id":"b9377b738186821b","type":"ui_group","name":"Plant Power","tab":"09d570a98f2d7086","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"830ea27574d20824","type":"ui_group","name":"Parameters Inverter 2","tab":"09d570a98f2d7086","order":5,"disp":true,"width":"6","collapse":false,"className":""},{"id":"afda8f86d6366faf","type":"ui_group","name":"Readings Inverter 2","tab":"09d570a98f2d7086","order":4,"disp":true,"width":"6","collapse":false,"className":""},{"id":"09d570a98f2d7086","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]
@makse-uk
Copy link

I have downloaded this and imported. put my API key in and try to run but get the following error 👍

node: Set Serial Numbers
function : (error)
"TypeError: Cannot read properties of undefined (reading 'serial')"

@GwelforBodad
Copy link
Author

Hi, sorry for the delay getting back to you. The flow should work in node red and send the data to HA for you. Once you have entered the API key into the inject node, you need to do a Deploy on the flow. That should embed your API key and trigger a read from the cloud, pulling back Inverter Serial Number and so on. Once this has been retrieved, the rest of the flow should work whenever triggered.

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