Givenergy to MQTT with Home Assistant auto-discovery
This is a flow that's currently a bit of a work in progress.
This flow uses the GivEnergy cloud API to get data about the inverter and battery usage. It then exports it to a local MQTT server and sets up auto discovery for Home Assistant to pick some things up as sensors.
[{"id":"f6f2187d.f17ca8","type":"tab","label":"GivEnergy.cloud","disabled":false,"info":""},{"id":"ccdb2874.ab7a18","type":"debug","z":"f6f2187d.f17ca8","name":"Battery Data Response","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1090,"y":920,"wires":[]},{"id":"b24cd458.b49cc","type":"comment","z":"f6f2187d.f17ca8","name":"Login to GivEnergy via cloud API","info":"ya know. cause\n\n# https://kb.givenergy.cloud/article.php?id=5","x":130,"y":40,"wires":[]},{"id":"7eee2f3.48c4c5","type":"inject","z":"f6f2187d.f17ca8","name":"Login","props":[{"p":"headers","v":"{\"Content-type\":\"application/x-www-form-urlencoded\"}","vt":"json"},{"p":"payload.account","v":"<your_username>","vt":"str"},{"p":"payload.password","v":"<yourpassword>","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"str","x":114,"y":130,"wires":[["b2f7a9b1.c2fc4"]]},{"id":"b2f7a9b1.c2fc4","type":"http request","z":"f6f2187d.f17ca8","name":"GivEnergy Login","method":"POST","ret":"txt","paytoqs":"ignore","url":"https://www.givenergy.cloud/GivManage/api/login","tls":"","persist":true,"proxy":"","authType":"","x":324,"y":130,"wires":[["e6cfdae3.a14ab8"]]},{"id":"cd7a7a2.d208888","type":"change","z":"f6f2187d.f17ca8","name":"Re-Authenticate","rules":[{"t":"set","p":"headers","pt":"msg","to":"{\"Content-type\":\"application/x-www-form-urlencoded\"}","tot":"str"},{"t":"set","p":"payload.account","pt":"msg","to":"<username>","tot":"str"},{"t":"set","p":"payload.password","pt":"msg","to":"<yourpassword>","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":300,"wires":[["b2f7a9b1.c2fc4"]]},{"id":"fefa9bf5.c6d208","type":"inject","z":"f6f2187d.f17ca8","name":"Trigger","props":[{"p":"topic","vt":"str"},{"p":"payload.dateText","v":"","vt":"date"}],"repeat":"14400","crontab":"","once":true,"onceDelay":0.1,"topic":"","x":60,"y":460,"wires":[["a93f4949.f03848"]]},{"id":"7ce8cafd.ede13c","type":"http request","z":"f6f2187d.f17ca8","name":"Get Battery Cell Data","method":"POST","ret":"txt","paytoqs":"ignore","url":"https://www.givenergy.cloud/GivManage/api/pcs/batCell/getBatCellData","tls":"","persist":false,"proxy":"","authType":"","x":740,"y":920,"wires":[["529aa07.d9e686"]]},{"id":"5a8de257.3c6584","type":"change","z":"f6f2187d.f17ca8","name":"Set serial number","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload","pt":"msg","to":"{\"plantId\":\"<your plant ID>\",\"type\":\"0\",\"serialNum\":\"<serial number>\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":503,"y":924,"wires":[["7ce8cafd.ede13c"]]},{"id":"a93f4949.f03848","type":"moment","z":"f6f2187d.f17ca8","name":"Today's date","topic":"","input":"payload.dateText","inputType":"msg","inTz":"Europe/London","adjAmount":0,"adjType":"days","adjDir":"add","format":"YYYY-MM-DD","locale":"en-US","output":"payload.dateText","outputType":"msg","outTz":"Europe/London","x":110,"y":540,"wires":[[]]},{"id":"56432a94.4ea86c","type":"http request","z":"f6f2187d.f17ca8","name":"Get Plant Devices","method":"POST","ret":"txt","paytoqs":"ignore","url":"https://www.givenergy.cloud/GivManage/api/plant/getPlantDevices","tls":"","persist":false,"proxy":"","authType":"","x":770,"y":640,"wires":[["b71a4c8.bcc0fb"]]},{"id":"932bcf16.3725c8","type":"change","z":"f6f2187d.f17ca8","name":"Set Plant ID","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload","pt":"msg","to":"{\"plantId\":\"<your plant ID>\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":640,"wires":[["56432a94.4ea86c"]]},{"id":"b5d7ffa4.6c835","type":"switch","z":"f6f2187d.f17ca8","name":"Succeed?","property":"statusCode","propertyType":"msg","rules":[{"t":"neq","v":"200","vt":"str"},{"t":"eq","v":"200","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":100,"y":320,"wires":[["cd7a7a2.d208888"],["fcc238de.e44408","3afda1e3.a46596","6c87547a.976e9c","a154ed8a.38f2b","d1b8ddf1.d9116","29affd13.37ed9a"]]},{"id":"49a50baf.04d474","type":"inject","z":"f6f2187d.f17ca8","name":"Start me up","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":90,"y":200,"wires":[[]]},{"id":"c9ca993f.de0ae8","type":"debug","z":"f6f2187d.f17ca8","name":"Devices Response","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1110,"y":600,"wires":[]},{"id":"8f3cd597.e9d5b8","type":"debug","z":"f6f2187d.f17ca8","name":"Login Response","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":580,"y":140,"wires":[]},{"id":"e6cfdae3.a14ab8","type":"change","z":"f6f2187d.f17ca8","name":"Set session variable","rules":[{"t":"set","p":"givEnergyHeaderCookie","pt":"flow","to":"headers.set-cookie","tot":"msg"},{"t":"set","p":"givEnergyResCookies","pt":"flow","to":"responseCookies","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":324,"y":210,"wires":[["d4ee3c94.2ba5f"]]},{"id":"2c8baa3a.093766","type":"http request","z":"f6f2187d.f17ca8","name":"Get plant summary","method":"POST","ret":"txt","paytoqs":"ignore","url":"https://www.givenergy.cloud/GivManage/api/plant/getPlantSummary","tls":"","persist":false,"proxy":"","authType":"","x":854,"y":210,"wires":[["b5d7ffa4.6c835","d8dbd7be.3dee38","c1e5d7f6.93911"]]},{"id":"f18ae8a.33fe598","type":"debug","z":"f6f2187d.f17ca8","name":"Plant summary","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1100,"y":220,"wires":[]},{"id":"d4ee3c94.2ba5f","type":"change","z":"f6f2187d.f17ca8","name":"form-urlencoded header","rules":[{"t":"set","p":"headers","pt":"msg","to":"{\"Content-type\":\"application/x-www-form-urlencoded\"}","tot":"json"},{"t":"set","p":"cookies","pt":"msg","to":"givEnergyResCookies","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":594,"y":210,"wires":[["2c8baa3a.093766"]]},{"id":"4eaa2e23.6318d8","type":"change","z":"f6f2187d.f17ca8","name":"form-urlencoded header","rules":[{"t":"set","p":"headers","pt":"msg","to":"{\"Content-type\":\"application/x-www-form-urlencoded\"}","tot":"json"},{"t":"set","p":"cookies","pt":"msg","to":"givEnergyResCookies","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":920,"wires":[["5a8de257.3c6584"]]},{"id":"fcc238de.e44408","type":"change","z":"f6f2187d.f17ca8","name":"form-urlencoded header","rules":[{"t":"set","p":"headers","pt":"msg","to":"{\"Content-type\":\"application/x-www-form-urlencoded\"}","tot":"json"},{"t":"set","p":"cookies","pt":"msg","to":"givEnergyResCookies","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":640,"wires":[["932bcf16.3725c8"]]},{"id":"b71a4c8.bcc0fb","type":"switch","z":"f6f2187d.f17ca8","name":"Succeed?","property":"statusCode","propertyType":"msg","rules":[{"t":"neq","v":"200","vt":"str"},{"t":"eq","v":"200","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":120,"y":760,"wires":[["cd7a7a2.d208888"],["4eaa2e23.6318d8","9fd68874.647aa"]]},{"id":"d8dbd7be.3dee38","type":"mqtt out","z":"f6f2187d.f17ca8","name":"","topic":"givenergy/cloud/summary","qos":"","retain":"","broker":"d04b7308.3e7f58","x":1090,"y":280,"wires":[]},{"id":"9fd68874.647aa","type":"mqtt out","z":"f6f2187d.f17ca8","name":"","topic":"givenergy/cloud/devices","qos":"","retain":"","broker":"d04b7308.3e7f58","x":1110,"y":740,"wires":[]},{"id":"a732ae86.08fbf8","type":"mqtt out","z":"f6f2187d.f17ca8","name":"","topic":"givenergy/cloud/batteryData","qos":"","retain":"","broker":"d04b7308.3e7f58","x":980,"y":1120,"wires":[]},{"id":"c1fd0ef9.bf4fe","type":"delay","z":"f6f2187d.f17ca8","name":"","pauseType":"delay","timeout":"10","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":920,"y":1040,"wires":[["d4ee3c94.2ba5f"]]},{"id":"5d20f7f5.2b9ee8","type":"mqtt out","z":"f6f2187d.f17ca8","name":"","topic":"homeassistant/sensor/GivEnergy_BatteryPower/G345/config","qos":"","retain":"","broker":"d04b7308.3e7f58","x":1520,"y":420,"wires":[]},{"id":"c42be291.797ee8","type":"mqtt out","z":"f6f2187d.f17ca8","name":"","topic":"givenergy/cloud/status","qos":"","retain":"","broker":"d04b7308.3e7f58","x":1280,"y":140,"wires":[]},{"id":"c1e5d7f6.93911","type":"switch","z":"f6f2187d.f17ca8","name":"Set topic state","property":"statusCode","propertyType":"msg","rules":[{"t":"neq","v":"200","vt":"str"},{"t":"eq","v":"200","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":860,"y":140,"wires":[["c983d358.776f2"],["715ebbd5.ec78b4"]]},{"id":"715ebbd5.ec78b4","type":"change","z":"f6f2187d.f17ca8","name":"Online","rules":[{"t":"set","p":"payload","pt":"msg","to":"Online","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1030,"y":160,"wires":[["c42be291.797ee8"]]},{"id":"c983d358.776f2","type":"change","z":"f6f2187d.f17ca8","name":"Offline","rules":[{"t":"set","p":"payload","pt":"msg","to":"Offline","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1030,"y":120,"wires":[["c42be291.797ee8"]]},{"id":"27d432e2.478a96","type":"mqtt out","z":"f6f2187d.f17ca8","name":"","topic":"homeassistant/sensor/GivEnergy_BatterySOC/G345/config","qos":"","retain":"","broker":"d04b7308.3e7f58","x":1520,"y":360,"wires":[]},{"id":"3afda1e3.a46596","type":"change","z":"f6f2187d.f17ca8","name":"HA Disc Conf (battery soc)","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"name\":\"Battery State of Charge (GE)\",\"stat_t\":\"givenergy/cloud/summary\",\"avty_t\":\"givenergy/cloud/status\",\"pl_avail\":\"Online\",\"pl_not_avail\":\"Offline\",\"json_attr_t\":\"givenergy/cloud/summary\",\"unit_of_meas\":\"%\",\"val_tpl\":\"{{value_json['soc']}}\",\"ic\":\"mdi:battery\",\"uniq_id\":\"G345-I-BattSoC-1\",\"device_class\":\"battery\",\"dev\":{\"ids\":[\"G345-I-BattSoC_1\"],\"mf\":\"GivEnergy\"}}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":1120,"y":360,"wires":[["27d432e2.478a96"]]},{"id":"6c87547a.976e9c","type":"change","z":"f6f2187d.f17ca8","name":"HA Disc Conf (battery power)","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"name\":\"Battery power (GE)\",\"stat_t\":\"givenergy/cloud/summary\",\"avty_t\":\"givenergy/cloud/status\",\"pl_avail\":\"Online\",\"pl_not_avail\":\"Offline\",\"unit_of_meas\":\"kW\",\"val_tpl\":\"{{value_json['batPower']}}\",\"ic\":\"mdi:battery-charging\",\"uniq_id\":\"G345-I-BattPower-1\",\"device_class\":\"power\",\"dev\":{\"ids\":[\"G345-I-BattPower_1\"],\"mf\":\"GivEnergy\"}}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":1120,"y":420,"wires":[["5d20f7f5.2b9ee8"]]},{"id":"523082bb.23e574","type":"mqtt out","z":"f6f2187d.f17ca8","name":"","topic":"homeassistant/sensor/GivEnergy_LoadPower/G345/config","qos":"","retain":"","broker":"d04b7308.3e7f58","x":1510,"y":480,"wires":[]},{"id":"a154ed8a.38f2b","type":"change","z":"f6f2187d.f17ca8","name":"HA Disc Conf (load power)","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"name\":\"Load power (GE)\",\"stat_t\":\"givenergy/cloud/summary\",\"avty_t\":\"givenergy/cloud/status\",\"pl_avail\":\"Online\",\"pl_not_avail\":\"Offline\",\"unit_of_meas\":\"kW\",\"val_tpl\":\"{{value_json['loadPowerkW']}}\",\"ic\":\"mdi:home-lightbulb\",\"uniq_id\":\"G345-I-LoadPower\",\"device_class\":\"power\",\"dev\":{\"ids\":[\"G345-I-LoadPower\"],\"mf\":\"GivEnergy\"}}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":1120,"y":480,"wires":[["523082bb.23e574"]]},{"id":"bc54e66e.9f5a2","type":"mqtt out","z":"f6f2187d.f17ca8","name":"","topic":"homeassistant/sensor/GivEnergy_PVPower/G345/config","qos":"","retain":"","broker":"d04b7308.3e7f58","x":1510,"y":540,"wires":[]},{"id":"d1b8ddf1.d9116","type":"change","z":"f6f2187d.f17ca8","name":"HA Disc Conf (PV power)","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"name\":\"Solar PV power (GE)\",\"stat_t\":\"givenergy/cloud/summary\",\"avty_t\":\"givenergy/cloud/status\",\"pl_avail\":\"Online\",\"pl_not_avail\":\"Offline\",\"unit_of_meas\":\"kW\",\"val_tpl\":\"{{value_json['pvPower']}}\",\"ic\":\"mdi:solar-power\",\"uniq_id\":\"G345-I-PVPower\",\"device_class\":\"power\",\"dev\":{\"ids\":[\"G345-I-PVPower\"],\"mf\":\"GivEnergy\"}}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":1110,"y":540,"wires":[["bc54e66e.9f5a2"]]},{"id":"c2ae18c6.bf046","type":"mqtt out","z":"f6f2187d.f17ca8","name":"","topic":"homeassistant/sensor/GivEnergy_GridPower/G345/config","qos":"","retain":"","broker":"d04b7308.3e7f58","x":1510,"y":600,"wires":[]},{"id":"29affd13.37ed9a","type":"change","z":"f6f2187d.f17ca8","name":"HA Disc Conf (Grid power)","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"name\":\"Grid power (GE)\",\"stat_t\":\"givenergy/cloud/summary\",\"avty_t\":\"givenergy/cloud/status\",\"pl_avail\":\"Online\",\"pl_not_avail\":\"Offline\",\"unit_of_meas\":\"kW\",\"val_tpl\":\"{{value_json['gridPowerKW']}}\",\"ic\":\"mdi:transmission-tower\",\"uniq_id\":\"G345-I-gridPower\",\"device_class\":\"power\",\"dev\":{\"ids\":[\"G345-I-gridPower\"],\"mf\":\"GivEnergy\"}}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":1120,"y":600,"wires":[["c2ae18c6.bf046"]]},{"id":"fb36df59.a1777","type":"change","z":"f6f2187d.f17ca8","name":"HA Disc Conf (Battery Data)","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"name\":\"Battery Data (GE)\",\"stat_t\":\"givenergy/cloud/batteryData\",\"avty_t\":\"givenergy/cloud/status\",\"pl_avail\":\"Online\",\"pl_not_avail\":\"Offline\",\"json_attr_t\":\"givenergy/cloud/batteryData\",\"unit_of_meas\":\"%\",\"val_tpl\":\"{{value_json['modules']['moduleSoc']}}\",\"ic\":\"mdi:battery-heart-variant\",\"uniq_id\":\"G345-I-BatteryData_1\",\"device_class\":\"battery\",\"dev\":{\"ids\":[\"G345-I-BatteryData-1\"],\"mf\":\"GivEnergy\"}}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":1220,"wires":[["7d29875a.bd347"]]},{"id":"7d29875a.bd347","type":"mqtt out","z":"f6f2187d.f17ca8","name":"","topic":"homeassistant/sensor/GivEnergy_BattData/G345/config","qos":"","retain":"","broker":"d04b7308.3e7f58","x":1090,"y":1220,"wires":[]},{"id":"3b614ef6.735aca","type":"comment","z":"f6f2187d.f17ca8","name":"Serial number","info":"Add it as a flow variable.\nFigure out how to push it into MQTT topics & inject it into the payload","x":1150,"y":700,"wires":[]},{"id":"529aa07.d9e686","type":"switch","z":"f6f2187d.f17ca8","name":"Succeed?","property":"statusCode","propertyType":"msg","rules":[{"t":"neq","v":"200","vt":"str"},{"t":"eq","v":"200","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":140,"y":1080,"wires":[["cd7a7a2.d208888"],["c1fd0ef9.bf4fe","a732ae86.08fbf8","fb36df59.a1777"]]},{"id":"3c99cf47.e89008","type":"comment","z":"f6f2187d.f17ca8","name":"Get battery - lifetime/annual data","info":"plant/getPlantEnergy","x":160,"y":420,"wires":[]},{"id":"d04b7308.3e7f58","type":"mqtt-broker","name":"your-mqtt","broker":"your-mqtt-server-like-mosquitto","port":"1883","clientid":"node-red1","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]