openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.9k stars 3.59k forks source link

[enphase] Monitor battery #16908

Open doits opened 5 months ago

doits commented 5 months ago

I see it is possible to monitor the envoy, inverters and relays with the enhpase addon. Could it be possible to monitor betteries, too?

I can get the data from the local API at /ivp/ensemble/inventory, which returns an array like this:

[
    {
        "type": "ENCHARGE",
        "devices": [
            {
                "part_num": "xxx",
                "installed": 123123123,
                "serial_num": "123123123",
                "device_status": [
                    "envoy.global.ok",
                    "prop.done"
                ],
                "last_rpt_date": 1719069361,
                "admin_state": 6,
                "admin_state_str": "ENCHG_STATE_READY",
                "created_date": 123123123,
                "img_load_date": 123123123,
                "img_pnum_running": "2.6.4134_rel/21.19",
                "zigbee_dongle_fw_version": "100F",
                "bmu_fw_version": "2.1.16",
                "operating": true,
                "communicating": true,
                "sleep_enabled": false,
                "percentFull": 100,
                "temperature": 28,
                "maxCellTemp": 29,
                "comm_level_sub_ghz": 4,
                "comm_level_2_4_ghz": 4,
                "led_status": 14,
                "dc_switch_off": false,
                "encharge_rev": 2,
                "encharge_capacity": 3500
            }
        ]
    }
]

A lot of information is visible, though I guess the most important is:

What is missing is the current power rate (watts pulling or pushing to the grid), not sure where to get this from.

Would this be a good addition? Or is there another endpoint to query?

lsiepel commented 5 months ago

What version of the envoy firmware do you use? Having this json is usefull to map it to the openHAB domain with channels and such.

Do you know what encharge_capacity means?

doits commented 4 months ago

What version of the envoy firmware do you use?

D7.6.358

Do you know what encharge_capacity means?

I think this is the storage capacity: 3.5kWh in this case.


I switched to /ivp/livedata/status and parsing the json output to monitor the battery though. There I get the current storage level and percent of the battery (and the current live values of the meters, too).

lsiepel commented 4 months ago

Can you share that JSON? I might try to build something this evening or tomorrow

doits commented 4 months ago

Sure, the important bits look like this:

{
  "meters": {
    "last_update": 1722325974,
    "soc": 100,
    "enc_agg_soc": 100,
    "enc_agg_energy": 10500,
    "acb_agg_soc": 0,
    "acb_agg_energy": 0,
    "pv": {
      "agg_p_mw": 1248663,
      "agg_s_mva": 1978937,
      "agg_p_ph_a_mw": 414719,
      "agg_p_ph_b_mw": 418743,
      "agg_p_ph_c_mw": 415201,
      "agg_s_ph_a_mva": 640268,
      "agg_s_ph_b_mva": 668520,
      "agg_s_ph_c_mva": 670149
    },
    "storage": {
      "agg_p_mw": 19000,
      "agg_s_mva": 19000,
      "agg_p_ph_a_mw": 19000,
      "agg_p_ph_b_mw": 0,
      "agg_p_ph_c_mw": 0,
      "agg_s_ph_a_mva": 19000,
      "agg_s_ph_b_mva": 0,
      "agg_s_ph_c_mva": 0
    },
    "grid": {
      "agg_p_mw": 41979,
      "agg_s_mva": 382063,
      "agg_p_ph_a_mw": 142328,
      "agg_p_ph_b_mw": -251883,
      "agg_p_ph_c_mw": 151533,
      "agg_s_ph_a_mva": 503622,
      "agg_s_ph_b_mva": -678988,
      "agg_s_ph_c_mva": 557427
    },
    "load": {
      "agg_p_mw": 1309642,
      "agg_s_mva": 2380000,
      "agg_p_ph_a_mw": 576047,
      "agg_p_ph_b_mw": 166860,
      "agg_p_ph_c_mw": 566734,
      "agg_s_ph_a_mva": 1162890,
      "agg_s_ph_b_mva": -10468,
      "agg_s_ph_c_mva": 1227576
    }
  }
}

Currently I only monitor:

To monitor it, you have to activate it every 15 minutes though, by POSTing '{"enable":1}' to /ivp/livedata/stream. And you need a bearer token, which you have to get from https://entrez.enphaseenergy.com/tokens. It is described at enhpase in this pdf on page 5.

lsiepel commented 4 months ago

My box is on older firmware and /ivp/ensemble/inventory gives 404. Same for /ivp/livedata/status

Getting a token from the cloud is adding dependency to a remote connection. To be honest; not sure if i want to code all that for a device that i don't use. If it was just grabbing the json from a local api and mapping it to openHAB channels i would be fine. Not saying i won;t but im to time cosntraint now to pick this up.