briancmpbll / home_assistant_custom_envoy

178 stars 76 forks source link

Exposing wNow from storage (battery) entity in production.json? #33

Open jackson-tim opened 1 year ago

jackson-tim commented 1 year ago

Looking to expose the wNow field from storage here to view the input/output wattage into/out of the batteries:

https:///production.json?details=1

e.g.:

  "storage": [
    {
      "type": "acb",
      "activeCount": 0,
      "readingTime": 0,
      "wNow": 0,
      "whNow": 0,
      "state": "idle"
    }
  ]

It's confusing sometimes to see high "consumption" wattage when the batteries are charging, and showing this value would help (and being able to do something like summing it with the overall consumption since it shows negative when charging, positive when discharging, etc).

I've poked through the reader, etc some but don't see exactly where this would be the easiest to add.

briancmpbll commented 1 year ago

I have a system where the battery info comes in through the /ivp/ensemble/inventory endpoint and not the /production.json endpoint. I would need someone with production.json to work on this.

jackson-tim commented 1 year ago

I can help with data/samples/access if it'd help. Let me know what data/help needed and I'll get it to you.

jackson-tim commented 1 year ago

Actually looking, I see all of the individual battery information under /ivp/ensemble/inventory but I don't see the input/output power to each battery there.

briancmpbll commented 1 year ago

Yeah, the /ivp/ensemble/inventory endpoint does not give input/output. I calculate the Battery Energy Charged and Discharged entities by taking the difference between the two most recent values of Total Battery Capacity. Does that give you want you need?

I suppose I can also calculate watts from the watt hours of the Battery Energy Charged/Discharged and elapsed time.

jackson-tim commented 1 year ago

The ivp endpoint doesn't, but the production.json does (even when the rest of the stats is in the ivp endpoint).. I've just worked around it for myself by adding CTs to the battery panel and to the load panel to view input/output there.

I get wh, etc from the batteries via /ivp/ensemble/inventory just real-time is in production.json in the storage bit..

isottipietro commented 1 year ago

@briancmpbll

Yeah, the /ivp/ensemble/inventory endpoint does not give input/output. I calculate the Battery Energy Charged and Discharged entities by taking the difference between the two most recent values of Total Battery Capacity. Does that give you want you need?

I suppose I can also calculate watts from the watt hours of the Battery Energy Charged/Discharged and elapsed time.

I found an endpoint exposing input/output power: https://envoy.local/ivp/ensemble/power

{
    "devices:": [
        {
            "serial_num": "xxx",
            "real_power_mw": -227000,
            "apparent_power_mva": -227000,
            "soc": 82
        },
        {
            "serial_num": "xxx",
            "real_power_mw": 0,
            "apparent_power_mva": 0,
            "soc": 14
        },
        {
            "serial_num": "xxx",
            "real_power_mw": -92000,
            "apparent_power_mva": -92000,
            "soc": 93
        },
        {
            "serial_num": "xxx",
            "real_power_mw": 0,
            "apparent_power_mva": 0,
            "soc": 8
        },
        {
            "serial_num": "xxx",
            "real_power_mw": -27000,
            "apparent_power_mva": -27000,
            "soc": 94
        },
        {
            "serial_num": "xxx",
            "real_power_mw": -88000,
            "apparent_power_mva": -88000,
            "soc": 100
        }
    ]
}

pwer is in mW soc is the battery percentage power_mw is negative when charging

software version on envoy is D7.6.111