krbaker / hass-sunpower

Home Assistant SunPower Integration using the local installer ethernet interface.
Apache License 2.0
63 stars 23 forks source link

Energy Usage and back to grid not calculating correctly #83

Open soul4soul opened 5 months ago

soul4soul commented 5 months ago

Set up this integration, solar panel data is coming in fine. total solar production is fine but back to grid and home energy usage aren't being calculated correctly in HA.

Example data from yesterday HA is adding grid + solar production. HA mySunPower app
image Screenshot_20240610_201721_mySunpower

HA Energy Config. I do noticed both devices end with a c but they are the only options I have. image

In FAQs I see you wrote

If your consumption is just wrong (the most common failure is seeing the solar production count as consumption) then the PVS is configured wrong Sunpower Training is what they should follow to resolve this.

Is this one of those issues?

Relevant output of deviclist command

"devices": [

        {
              "DETAIL": "detail",
              "STATE": "working",
              "STATEDESCR": "Working",
              "SERIAL": "ZT224385000549W3031",
              "MODEL": "PV Supervisor PVS6",
              "HWVER": "6.02",
              "SWVER": "2023.3, Build 61410",
              "DEVICE_TYPE": "PVS",
              "DATATIME": "2024,06,11,11,35,00",
              "dl_err_count": "0",
              "dl_comm_err": "304",
              "dl_skipped_scans": "0",
              "dl_scan_time": "2",
              "dl_untransmitted": "752515",
              "dl_uptime": "273871",
              "dl_cpu_load": "0.57",
              "dl_mem_used": "87044",
              "dl_flash_avail": "53653",
              "panid": 2003552054,
              "CURTIME": "2024,06,11,11,38,25"
        },
        {
              "ISDETAIL": true,
              "SERIAL": "PVS6M22433031p",
              "TYPE": "PVS5-METER-P",
              "STATE": "working",
              "STATEDESCR": "Working",
              "MODEL": "PVS6M0400p",
              "DESCR": "Power Meter PVS6M22433031p",
              "DEVICE_TYPE": "Power Meter",
              "interface": "mime",
              "production_subtype_enum": "GROSS_PRODUCTION_SITE",
              "subtype": "GROSS_PRODUCTION_SITE",
              "SWVER": "3000",
              "PORT": "",
              "DATATIME": "2024,06,11,11,38,24",
              "ct_scl_fctr": "50",
              "net_ltea_3phsum_kwh": "8452.2199",
              "p_3phsum_kw": "0.7375",
              "q_3phsum_kvar": "-0.2875",
              "s_3phsum_kva": "0.7959",
              "tot_pf_rto": "0.9298",
              "freq_hz": "60",
              "i_a": "3.2335",
              "v12_v": "246.1571",
              "CAL0": "50",
              "origin": "data_logger",
              "OPERATION": "noop",
              "CURTIME": "2024,06,11,11,38,26"
        },
        {
              "ISDETAIL": true,
              "SERIAL": "PVS6M22433031c",
              "TYPE": "PVS5-METER-C",
              "STATE": "working",
              "STATEDESCR": "Working",
              "MODEL": "PVS6M0400c",
              "DESCR": "Power Meter PVS6M22433031c",
              "DEVICE_TYPE": "Power Meter",
              "interface": "mime",
              "consumption_subtype_enum": "GROSS_CONSUMPTION_LINESIDE",
              "subtype": "GROSS_CONSUMPTION_LINESIDE",
              "SWVER": "3000",
              "PORT": "",
              "DATATIME": "2024,06,11,11,38,25",
              "ct_scl_fctr": "100",
              "net_ltea_3phsum_kwh": "10699.04",
              "p_3phsum_kw": "0.4933",
              "q_3phsum_kvar": "-0.0231",
              "s_3phsum_kva": "0.6048",
              "tot_pf_rto": "0.8172",
              "freq_hz": "60",
              "i1_a": "3.033",
              "i2_a": "1.8811",
              "v1n_v": "123.0921",
              "v2n_v": "123.0526",
              "v12_v": "246.1445",
              "p1_kw": "0.2917",
              "p2_kw": "0.2015",
              "neg_ltea_3phsum_kwh": "0",
              "pos_ltea_3phsum_kwh": "10699.2",
              "CAL0": "100",
              "origin": "data_logger",
              "OPERATION": "noop",
              "CURTIME": "2024,06,11,11,38,26"
        },
soul4soul commented 5 months ago

Tried to do a little investigating into this myself. So I found how kwh to gird and kwh to home are set. https://github.com/krbaker/hass-sunpower/blob/main/custom_components/sunpower/const.py#L353-L367

Looking at the output I shared above my neg_ltea_3phsum_kwh is always 0 but comparing my output to those posted by others and the sample output it almost looks like neg_ltea_3phsum_kwh equals the production meter net_ltea_3phsum_kwh and that pos_ltea_3phsum_kwh equals consumption meter net_ltea_3phsum_kwh. Those fields map to the meters lifetime power so I updated HA to use those fields.

image

At least I see consumption and production now but the energy distribution for the day, self consumed solar, and self-sufficiency charts now don't work. HA things all solar energy is sent to grid and then all energy comes from the grid. Overall seems like a step in the right direction but still not working as expected.

image

edhuang04 commented 4 months ago

Do you not have a value under your Consumption sensor that details out KWH to the home and KWH to the grid?

image

those are the values i use to set grid and return to grid values.

as for production i pull the lifetime power production from the production device.

image

soul4soul commented 4 months ago

KWH to grid always shows 0 for me. image

Also the sunpower app works fine and shows energy going back to the grid.