Cookie Consent by Free Privacy Policy Generator

Heartbeat Daten bei GridX abgreifen.

Per Curl kann man die Daten von gridx bekommen die sonst im Heartbeat/App/Webseite landen.

Es gibt eine Integration von Heartbeat von Home Assistant gibt es auf Github. Leider hat sie bei mir nicht funktioniert und ich habe dann in der Facebook Gruppe gelesen, dass dies nur mit der alten Webseite ging.

Jetzt habe ich mir das mal angeschaut was da genau passiert bei der neuen Webseite. Da einmal einloggen und die Console und Network Traffic aufmachen. Da sehe ich wie Daten bei https://api.gridx.de/systems/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/live abgeholt werden. Das xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx ist für jedes System individuell.  

API Aufruf der Daten

Dann gibt es da einen Authorization Header der den Bearer enthält. Da wird es spannend noch rauszufinden sein, wie man den immer wieder dynamisch bekommt bzw. wie lange der gilt.

Update: Beim Einloggen sehe ich im Netzwerktraffic, dass ich das token auf einen Post Request auf https://gridx.eu.auth0.com/oauth/token eine Response gibt mit, access_token, refresh_token, id_token, scope, expires_in und token_type gibt.

expires_in ist 86400. Wenn das Sekunden sind, dann sind das 24h.

Network Traffic

Wenn ich das jetzt per curl auf der Kommandozeile mache bekomme ich bei:

curl -X GET -f -k -H 'Authorization:Bearer eyJhbGc-SUPER-SECRET-BEARER' https://api.gridx.de/systems/dxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /live|jq

Eine schöne Übersicht über mein System:

{
  "batteries": [
    {
      "applianceID": "XXXXXXXXXXXXX",
      "capacity": 10185,
      "nominalCapacity": 10500,
      "power": 0,
      "remainingCharge": 9981.3,
      "stateOfCharge": 0.98
    }
  ],
  "battery": {
    "capacity": 10185,
    "nominalCapacity": 10500,
    "power": 0,
    "remainingCharge": 9981.3,
    "stateOfCharge": 0.98
  },
  "consumption": 692.463,
  "directConsumption": 692.463,
  "directConsumptionEV": 0,
  "directConsumptionHeatPump": 0,
  "directConsumptionHeater": 0,
  "directConsumptionHousehold": 692.463,
  "directConsumptionRate": 0.09471359131274716,
  "grid": -6618.663,
  "gridL1": -2196.15,
  "gridL2": -2201.267,
  "gridL3": -2221.246,
  "measuredAt": "2024-09-20T12:00:04Z",
  "photovoltaic": 7311.126,
  "production": 7311.126,
  "selfConsumption": 692.463,
  "selfConsumptionRate": 0.09471359131274716,
  "selfSufficiencyRate": 1,
  "selfSupply": 692.463,
  "totalConsumption": 692.463
}

Weiterhin gibt es die Endpunkte:

  • /weather
  • /applicances
  • /gateways

die folgende Daten tragen:

/weather

{
    "city": "Berlin",
    "icon": "night",
    "measuredAt": "2024-09-20T11:54:26Z",
    "sunRise": "2024-09-20T04:49:17Z",
    "sunSet": "2024-09-20T17:10:05Z",
    "temperature": 14.3
}

/appliances

[
    {
        "battery": {
            "controllable": true,
            "maxCharge": 3500000,
            "maxDischarge": 3500000
        },
        "connectionStatus": {
            "contactedAt": "2024-09-20T11:54:26Z",
            "status": "AVAILABLE"
        },
        "createdAt": "2023-01-18T09:52:06Z",
        "cryptoSettings": [
            {
                "createdAt": "2023-01-18T09:55:11Z",
                "key": "KEYKEYKEY",
                "updatedAt": "2023-01-18T09:55:11Z"
            },
          {
            // 81 more crypto settings
          }
            
        ],
        "energySettings": {
            "minControlInterval": 10000,
            "phaseMapping": [
                0,
                1,
                2
            ],
            "socDeepDischarge": 4,
            "socLockMax": 98,
            "socLockMin": 12,
            "socMax": 100,
            "socMin": 4,
            "updatedAt": "2024-09-19T13:27:20Z"
        },
        "firmware": "D8.2.4264",
        "hybridCalcMode": 0,
        "id": "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx",
        "inactive": false,
        "inverter": {
            "type": "ENPHASE_ENVOY_S"
        },
        "kind": "HYBRID",
        "loadSettings": {
            "disabled": false
        },
        "manufacturer": "Enphase",
        "model": "Envoy S",
        "network": {
            "address": "MY_LOCAL_ENVOY_IP"
        },
        "nominalPowerLimit": 13908000,
        "position": 0,
        "reverseFlow": false,
        "serialnumber": "SERNUMBER",
        "source": {
            "origin": "GRIDBOX",
            "uri": "gateways/SOMEID"
        },
        "state": {
            "current": "CONNECTED",
            "desired": "CONNECTING",
            "transitions": [
                {
                    "start": "CONNECTING",
                    "target": "DISCONNECTED"
                },
                {
                    "start": "CONNECTED",
                    "target": "DISCONNECTED"
                },
                {
                    "start": "DISCONNECTED",
                    "target": "CONNECTING"
                }
            ]
        },
        "status": "OK",
        "type": "INVERTER",
        "updatedAt": "2024-09-19T13:27:20Z"
    },
    {
        "auxMeter": {
            "location": "GRID",
            "type": "ENPHASE_ENVOY_S_METER_TYPE"
        },
        "connectionStatus": {
            "contactedAt": "2024-09-20T11:54:26Z",
            "status": "AVAILABLE"
        },
        "createdAt": "2023-01-18T09:52:06Z",
        "cryptoSettings": [
            // more Settings
        ],
        "energySettings": {
            "minControlInterval": 0,
            "phaseMapping": [
                0,
                1,
                2
            ],
            "socDeepDischarge": 0,
            "socLockMax": 0,
            "socLockMin": 0,
            "socMax": 0,
            "socMin": 0,
            "updatedAt": "2024-09-19T13:27:20Z"
        },
        "firmware": "03.02.08",
        "id": "SOMEID",
        "inactive": false,
        "kind": "GRID",
        "loadSettings": {
            "disabled": false
        },
        "manufacturer": "UNKNOWN",
        "model": "Envoy-s meter",
        "network": {
            "address": "MY_LOCAL_ENVOY_IP"
        },
        "position": 1,
        "reverseFlow": false,
        "serialnumber": "SERNUMBER-meter",
        "source": {
            "origin": "GRIDBOX",
            "uri": "gateways/SOMEID"
        },
        "state": {
            "current": "CONNECTED",
            "desired": "CONNECTING",
            "transitions": [
                {
                    "start": "CONNECTING",
                    "target": "DISCONNECTED"
                },
                {
                    "start": "CONNECTED",
                    "target": "DISCONNECTED"
                },
                {
                    "start": "DISCONNECTED",
                    "target": "CONNECTING"
                }
            ]
        },
        "status": "OK",
        "type": "METER",
        "updatedAt": "2024-09-19T13:27:20Z"
    }
]

/gateways

[
    {
        "additionalIdentifiers": [
            {
                "identifier": "SOME IDENTIFIER",
                "service": "EEBUS",
                "type": "SKI"
            }
        ],
        "applianceComposition": [
            "BATTERY",
            "GRID",
            "HYBRID",
            "PV"
        ],
        "connectionStatus": {
            "contactedAt": "2024-09-20T11:53:24Z",
            "status": "AVAILABLE"
        },
        "createdAt": "2023-01-18T09:51:55Z",
        "debugModeUntil": "2023-01-21T09:51:55Z",
        "id": "SOME ID",
        "internalDeviceID": "SOME INTERNAL DEVICE ID",
        "manufacturer": "gridX",
        "model": "4.00P-X",
        "registeredAt": "2023-01-18T09:51:55Z",
        "scanners": [
            "SMA_INVERTER_IGMP_HOST_DISCOVERY",
            "SMA_INVERTER_ARP_HOST_DISCOVERY",
            "SMA_METER",
            "BCONTROL_METER",
            "SOLAREDGE_INVERTER_METER_MODBUS_TCP",
            "SOLAREDGE_INVERTER_METER_MODBUS_RTU",
            "FRONIUS_INVERTER",
            "KEBA_CHARGING_STATION",
            "ABL_CHARGING_STATION",
            "SIEMENS_PAC_METER",
            "KOSTAL_INVERTER_PLENTICORE",
            "MENNEKES_UPNP",
            "ALFEN_NG9XX_MODBUS_CHARGING_STATION",
            "MY_PV_AC_THOR_HEATER",
            "BENDER_CHARGING_STATION",
            "HEIDELBERG_ENERGY_CONTROL_MODBUS_RTU_CHARGING_STATION",
            "SUNGROW_MODBUS_INVERTER",
            "VESTEL_CHARGING_STATION",
            "GOE_CHARGING_STATION",
            "ENPHASE_ENVOY_S_GATEWAY",
            "STIEBEL_ELTRON_MODBUS_TCP_HEAT_PUMP",
            "MENNEKES_AMTRON_COMPACT_2S_MODBUS_RTU_CHARGING_STATION",
            "SUNGROW_SG_MODBUS_INVERTER",
            "DAIKIN_HOMEHUB_MODBUS_TCP_HEAT_PUMP",
            "SUNGROW_SHXRS_SHXT_MODBUS_INVERTER"
        ],
        "serialnumber": "SERIAL NUMBER",
        "startcode": "SOME STARTCODE",
        "system": {
            "createdAt": "2022-12-12T20:30:26Z",
            "id": "SOME ID",
            "metadata": {
                "energy": {
                    "curtailment": -0.5,
                    "ems": {
                        "agreedDynamicPVControlTerms": false,
                        "agreedEMSTerms": true,
                        "agreedForecastBasedEMSTerms": false,
                        "agreedPriorityConfigurationTerms": false,
                        "enabledDynamicPVControl": false,
                        "enabledEMS": true,
                        "enabledForecastBasedEMS": true,
                        "enabledPriorityConfiguration": true,
                        "excludeApplianceTypes": null
                    },
                    "heatingSystem": "Strom",
                    "installer": "1KOMMA5° Berlin",
                    "norminalPower": 15400
                },
                "energySupplier": {
                    "baseFee": 13.99,
                    "feedInTariff": 8.2,
                    "unitPrice": 35.8
                },
                "wizard": {
                    "step": "DONE"
                }
            },
            "name": "Oliver Wehrens",
            "operatingSince": "2023-01-18T09:52:21Z",
            "productOptionUpdatedAt": "2023-12-01T14:30:33Z",
            "solution": "HOME",
            "updatedAt": "2023-12-01T14:30:33Z"
        },
        "type": "PHYSICAL",
        "updatedAt": "2023-01-18T09:51:55Z",
        "vendorID": "341799e6-1cde-42f7-9d7c-cab0f11ca8ac"
    }
]