GivEnergy - Battery/Inverter + home power things

Recently I had a GivEnergy battery fitted to the at the house. Of course I decided to make things difficult, so each component of my micro-power-plant is from a different manufacturer. Home Assistant to the rescue!

So while cutting down from 3 apps to one (HA), I was bashing my head against the RestAPI not working for GivEnergy in Home Assistant. Since I’m not known for giving up easily… I figured Node-Red may be able to help. I’d been meaning to figure it out. So after a crash course yesterday and mucking about with the API and figuring out MQTT sensor auto discovery in Home Assistant, here’s my first stab (I’ll update things that aren’t finished as I go and any suggestions welcome).

[
    {
        "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": ""
    }
]

Be sure to replace the placeholder data I put in with your own (username, password, plantID, inverter serial numbers, MQTT hosts). Then just head back into Home Assistant, and if you’ve got MQTT integration set up, it should show up. … in node red, you need to trigger the login once. I forgot to set that before I grabbed the code and I’m now too hungry (dinner time!) to fix it now. :slight_smile:

On the to-do list:

  1. Set the serial number as a flow variable, use that to populate the auto discovery stuff for things like, serial numbers, firmware versions, etc.
  2. Finish the battery integration.
  3. Figure out how to get this ‘power wheel’ card working with the data from this battery (cloud api), zappi charger(via their API) and solaredge (modbus)
  4. Carry on talking to GivEnergy to get the local API.
  5. Start talking to MyEnergi (Zappi) to get a local API to their hub.
  6. Learn python so I can create custom components for these things.

@Bergals, Great work.
I’m just about to get the GivEnergy system installed. I wanted to ask if there is any API calls on the cloud to control the battery mode? Ideally I’d like to set discharge and charge modes from automations etc…

Glad to see I’m not alone in this. I’ve got the set up working, but periodically it does fall over and you need to restart the flow. I have tweaked this to get things stable, however, I haven’t figured out how to set the charge/discharge state - it’s deffo on the to do list and I think I saw it in the API.

What I’m trying to figure out is how to get hold of modbus data for proper data analysis in real time… and I think it just needs to be plugged , so may test that out if I can find a long enough ethernet cable.

If you crack the charge/discharge set up via the API let me know. It’s something I’m keen on doing too, but it’s going to become more pressing to get this working with summer on the horizon and now that I’ve got a functional Octopus Agile API connection going. :wink:

Hi Bergals,

Ooh, really excited by this one, just trying to get it up and running now, but ow do i find my plantid ?

Thanks,
Eamon

Hi Bergals,

I think I found my plat id, and hjave mamaged to get node red connected, and entities created, and am now showing graphs for pv generation, battery SOC, Load, Grid power etc,

However, the flow does seem to be producing errors at the re-authenticate node, not sure what this is related to. Obvjoiusly id I disconenct the links the error stops, but i also notice some time inconsistencies between last reported data from the different data sets, with solar pv power bing relatively regularly updated, but the others not ?

image

I’ve not got mine installed yet, so I can’t Check. Does it have a LAN port or a cat5 Rs485 port built in?
I’ve got the modbus documents for the inverter and it suggests modbus TCP is available. Happy to share the docs if it helps. I’ve not dabbled in modbus before, but might need to see what I can do!

There are different dongles come with it. My system is 2 years old now, it came with a WiFi dongle, but at the time they were looking at bringing in one with a wired rj45 connection as well, I got a prototype version of it, so wired and wireless. I’ve wired it up direct to my.switch.

Ask for a wired version if it works for you.

By the way, the givenergy kit is excellent, can’t fault it.

1 Like

I wonder if its the same as the Solax one… I have a LAN dongle for my current Solax X1 invertor which looks the same design as the GivEnergy Wifi one. Might give that a go once its installed!

I’ve been speaking to the GivEnergy team to see if there is a way to connect to the invertor by Modbus, they say not.
But they are about to update the portal and the API to allow control of charging mode. Hopefully this will allow greater integration into Home Assistant.

Hi all, If anyone is interested and isn’t already, there’s a small developer community for the GivEnergy system and its discussing beta access to more info and control capability. If you are interested let me know and I can put you in touch with the Tech Director at GivEnergy.

1 Like

Hi Mark,
I just got a GivEnergy system installed and can successfully use their API to collect data from their cloud API. However the update rate is much lower than I expected. So I was looking if there was local access to the inverter. So if the community is looking at that I am very interested in taking part.

Would appreciate any more info you have or to put me in contact with the group.

Regards Tony.

1 Like

Tony,
If you contact Dan Lambert at GivEnergy on: GivEnergy Support [email protected] and ask to be included in the Developers Teams communitity I’m sure he’ll add you in. You need to sign an NDA, but once you have I can certainly share my Node-Red flows which allow me to control the system from within HA and extract various data stats.
It’s worth noting that the current limitation of 5min updates still exists, but is soon to be made configurable down to 10s (still via cloud) and then they are looking at different methods for local connectivity (MQTT or API), but that is still a way of I think.

Mark

Hey folks,

Sorry - I got distracted not paying attention to the forum!
As far as hardware connections go - if you plug in an ethernet cable onto their inverter, I THINK you maybe able to collect modbus data from it. I haven’t been brave enough to turn off systems to get it… so may call the installer back to plug in an ethernet cable for me.

Otherwise, random things on the to-do list:

  1. I think it’s done, working okay for me.
  2. Last thing which I’ll attempt today is using the cloud API to set charge timers IF the weather is done (which involved me going down this rabbit hole of solar generation forecasting)
  3. Mostly done, a few calculations are buggy but on the whole it’s working nice and neat. :smiley:
  4. Well - on their dev community periodically between work, rabit holes and other distractions.
  5. Sadly haven’t been speakting to them to the success of the GivEnergy team. :frowning:
  6. Well, that’s on the to-do list still… innocent whistle

Hi @Bergals
Thanks for your hard work on this - I am interested in getting a Givenergy inverter but wondered if you, @britkat, (or someone else) has managed to control charging/discharging from HA.
PS if it is possible, it might be worth posting the answer in this thread] to help anyone looking for an inverter that can do this.
Thanks

@AP05TLE , We do have local control working now for GivEnergy invertors which allows both reading of stats, and discharge/charge control including timeslots etc… This currently runs as a Docker container and I use Node-Red to link into HA. One day I want get a native integration, but haven’t had the time yet.

1 Like

Thanks - that is great news. It is certainly very high on my shortlist now
+1 for a native integration if you find the time
Thanks again

haha. Again, I’ve been distracted (this time by holidays and general life admin). @britkat and the team have been doing a great job without needing to wire cables from the inverter. It’s working like a charm for me. I was about to start poking about ot see if it’d integrate with the native “energy” features now in HA. But alas the wife is calling me to help out with something else. :smiley:

Hi there,

I’m getting a Givenergy AC inverter & battery installed tomorrow, just wondered how the development is going and if I can test in anyway?

Cheers

Simon

If you contact GivEnergy in the UK and ask to speak to the developers, you should be able to get access to a dev environment. I’m running off local API (ModBus over TCP), so it could all work. :slight_smile: DM me if you don’t come right.

I also just had my SolarEdge/GivEnergy system installed and I would like to use the API.

when you say Contact GivEnergy, I am guesting that you sent a email to the support desk ?

has anyone used the API and if so what were you findings ?