briancmpbll / home_assistant_custom_envoy

177 stars 77 forks source link

v0.0.18: issue with lifetime_net_energy_production and lifetime_net_energy_consumption #164

Closed lovelyday0 closed 1 year ago

lovelyday0 commented 1 year ago

Hello, In v0.0.17, the addition of _indexexport and _indeximport was really nice. v0.0.18 release note says that they were renamed to _lifetime_net_energyproduction and _lifetime_net_energyconsumption. However, it looks like this is not just a renaming: _lifetime_net_energyproduction is stuck to 0 (_indexexport was reporting the total Wh since Envoy installation) _lifetime_net_energyconsumption is incrementing correctly but started at value -479595 (_indeximport was reporting the total Wh since Envoy installation).

My configuration: Envoy S metered EU with CT clamps Firmware D7.6.175

From debug json: "entry": { "entry_id": "REDACTED", "version": 1, "domain": "enphase_envoy", "title": "Envoy REDACTED, "data": { "host": "192.168.1.100", "username": "REDACTED", "password": "REDACTED", "serial": "REDACTED", "use_enlighten": true, "name": "Envoy REDACTED" }, "options": { "data_interval": 60, "data_fetch_timeout_seconds": 30, "data_fetch_retry_count": 1, "data_fetch_holdoff_seconds": 0, "data_collection_timeout_seconds": 55, "do_not_use_production_json": false }, "pref_disable_new_entities": false, "pref_disable_polling": false, "source": "zeroconf", "unique_id": "REDACTED", "disabled_by": null }, "data": { "production": 0, "daily_production": 10260, "seven_days_production": 68631, "lifetime_production": 2694538, "lifetime_net_production": 0, "consumption": 332, "net_consumption": 332, "daily_consumption": 4937, "seven_days_consumption": 18, "lifetime_consumption": 2207300, "lifetime_net_consumption": -479550,

catsmanac commented 1 year ago

Hi @lovelyday0, that is unexpected, can you share the raw data from the diagnostic report? The diagnostic report is available on the Enphase Envoy device page in settings. In the downloaded file search for the section containing the Endpoint information.

        "Endpoint-production_json": "{\"production\":[{\"type\":\"inverters\",\

This is the raw data collected from the Envoy in the last scan. Can you share the endpoints to identify where these numbers are coming from?

lovelyday0 commented 1 year ago

Here it is:

"Endpoint-production_json": "{\"production\":[{\"type\":\"inverters\",\"activeCount\":7,\"readingTime\":1695455408,\"wNow\":1498,\"whLifetime\":331961},{\"type\":\"eim\",\"activeCount\":1,\"measurementType\":\"production\",\"readingTime\":1695455467,\"wNow\":1783.578,\"whLifetime\":2696047.98,\"varhLeadLifetime\":0.164,\"varhLagLifetime\":584314.829,\"vahLifetime\":3055032.302,\"rmsCurrent\":7.547,\"rmsVoltage\":236.987,\"reactPwr\":103.772,\"apprntPwr\":1786.99,\"pwrFactor\":1.0,\"whToday\":1509.98,\"whLastSevenDays\":62996.98,\"vahToday\":2448.302,\"varhLeadToday\":0.164,\"varhLagToday\":1123.829,\"lines\":[{\"wNow\":1783.578,\"whLifetime\":2696047.98,\"varhLeadLifetime\":0.164,\"varhLagLifetime\":584314.829,\"vahLifetime\":3055032.302,\"rmsCurrent\":7.547,\"rmsVoltage\":236.987,\"reactPwr\":103.772,\"apprntPwr\":1786.99,\"pwrFactor\":1.0,\"whToday\":1509.98,\"whLastSevenDays\":62996.98,\"vahToday\":2448.302,\"varhLeadToday\":0.164,\"varhLagToday\":1123.829}]}],\"consumption\":[{\"type\":\"eim\",\"activeCount\":1,\"measurementType\":\"total-consumption\",\"readingTime\":1695455467,\"wNow\":259.785,\"whLifetime\":2230329.471,\"varhLeadLifetime\":1456778.208,\"varhLagLifetime\":-583483.765,\"vahLifetime\":4195596.849,\"rmsCurrent\":1.022,\"rmsVoltage\":237.095,\"reactPwr\":-145.975,\"apprntPwr\":242.365,\"pwrFactor\":1.0,\"whToday\":15667.471,\"whLastSevenDays\":5.471,\"vahToday\":18594.849,\"varhLeadToday\":7665.208,\"varhLagToday\":0.0,\"lines\":[{\"wNow\":259.785,\"whLifetime\":2230329.471,\"varhLeadLifetime\":1456778.208,\"varhLagLifetime\":-583483.765,\"vahLifetime\":4195596.849,\"rmsCurrent\":1.022,\"rmsVoltage\":237.095,\"reactPwr\":-145.975,\"apprntPwr\":242.365,\"pwrFactor\":1.0,\"whToday\":15667.471,\"whLastSevenDays\":5.471,\"vahToday\":18594.849,\"varhLeadToday\":7665.208,\"varhLagToday\":0.0}]},{\"type\":\"eim\",\"activeCount\":1,\"measurementType\":\"net-consumption\",\"readingTime\":1695455467,\"wNow\":-1523.792,\"whLifetime\":-458031.358,\"varhLeadLifetime\":1456778.371,\"varhLagLifetime\":831.064,\"vahLifetime\":4195596.849,\"rmsCurrent\":-6.525,\"rmsVoltage\":237.095,\"reactPwr\":-249.747,\"apprntPwr\":-1546.967,\"pwrFactor\":-1.0,\"whToday\":0,\"whLastSevenDays\":0,\"vahToday\":0,\"varhLeadToday\":0,\"varhLagToday\":0,\"lines\":[{\"wNow\":-1523.792,\"whLifetime\":-458031.358,\"varhLeadLifetime\":1456778.371,\"varhLagLifetime\":831.064,\"vahLifetime\":4195596.849,\"rmsCurrent\":-6.525,\"rmsVoltage\":237.095,\"reactPwr\":-249.747,\"apprntPwr\":-1546.967,\"pwrFactor\":-1.0,\"whToday\":0,\"whLastSevenDays\":0,\"vahToday\":0,\"varhLeadToday\":0,\"varhLagToday\":0}]}],\"storage\":[{\"type\":\"acb\",\"activeCount\":0,\"readingTime\":0,\"wNow\":0,\"whNow\":0,\"state\":\"idle\"}]}",

catsmanac commented 1 year ago

Thanks, and if they are in there the ones with meters and meters_reports as well?

lovelyday0 commented 1 year ago

meters: "Endpoint-meters": "[\n {\n \"eid\": 704643328,\n \"state\": \"enabled\",\n \"measurementType\": \"production\",\n \"phaseMode\": \"three\",\n \"phaseCount\": 1,\n \"meteringStatus\": \"normal\",\n \"statusFlags\": []\n },\n {\n \"eid\": 704643584,\n \"state\": \"enabled\",\n \"measurementType\": \"net-consumption\",\n \"phaseMode\": \"three\",\n \"phaseCount\": 1,\n \"meteringStatus\": \"normal\",\n \"statusFlags\": []\n }\n]",

meters_reports: "Endpoint-meters-reports": "[\n {\n \"createdAt\": 1695455467,\n \"reportType\": \"production\",\n \"cumulative\": {\n \"currW\": 1780.570,\n \"actPower\": 1780.570,\n \"apprntPwr\": 1784.396,\n \"reactPwr\": 103.046,\n \"whDlvdCum\": 2696047.483,\n \"whRcvdCum\": 1379.946,\n \"varhLagCum\": 584314.799,\n \"varhLeadCum\": 0.164,\n \"vahCum\": 3055031.805,\n \"rmsVoltage\": 236.956,\n \"rmsCurrent\": 7.535,\n \"pwrFactor\": 1.00,\n \"freqHz\": 50.12\n },\n \"lines\": [\n {\n \"currW\": 1780.570,\n \"actPower\": 1780.570,\n \"apprntPwr\": 1784.396,\n \"reactPwr\": 103.046,\n \"whDlvdCum\": 2696047.483,\n \"whRcvdCum\": 1379.946,\n \"varhLagCum\": 584314.799,\n \"varhLeadCum\": 0.164,\n \"vahCum\": 3055031.805,\n \"rmsVoltage\": 236.956,\n \"rmsCurrent\": 7.535,\n \"pwrFactor\": 1.00,\n \"freqHz\": 50.12\n }\n ]\n },\n {\n \"createdAt\": 1695455467,\n \"reportType\": \"net-consumption\",\n \"cumulative\": {\n \"currW\": -1520.577,\n \"actPower\": -1520.577,\n \"apprntPwr\": -1542.837,\n \"reactPwr\": -249.889,\n \"whDlvdCum\": -458030.934,\n \"whRcvdCum\": 0.000,\n \"varhLagCum\": 831.064,\n \"varhLeadCum\": 1456778.303,\n \"vahCum\": 4195596.420,\n \"rmsVoltage\": 237.049,\n \"rmsCurrent\": -6.509,\n \"pwrFactor\": -1.00,\n \"freqHz\": 50.12\n },\n \"lines\": [\n {\n \"currW\": -1520.577,\n \"actPower\": -1520.577,\n \"apprntPwr\": -1542.837,\n \"reactPwr\": -249.889,\n \"whDlvdCum\": -458030.934,\n \"whRcvdCum\": 0.000,\n \"varhLagCum\": 831.064,\n \"varhLeadCum\": 1456778.303,\n \"vahCum\": 4195596.420,\n \"rmsVoltage\": 237.049,\n \"rmsCurrent\": -6.509,\n \"pwrFactor\": -1.00,\n \"freqHz\": 50.12\n }\n ]\n },\n {\n \"createdAt\": 1695455467,\n \"reportType\": \"total-consumption\",\n \"cumulative\": {\n \"currW\": 259.993,\n \"actPower\": 259.993,\n \"apprntPwr\": 243.254,\n \"reactPwr\": -146.843,\n \"whDlvdCum\": 2230329.398,\n \"whRcvdCum\": 0.000,\n \"varhLagCum\": -583483.735,\n \"varhLeadCum\": 1456778.139,\n \"vahCum\": 4195596.420,\n \"rmsVoltage\": 237.049,\n \"rmsCurrent\": 1.026,\n \"pwrFactor\": 1.00,\n \"freqHz\": 50.12\n },\n \"lines\": [\n {\n \"currW\": 259.993,\n \"actPower\": 259.993,\n \"apprntPwr\": 243.254,\n \"reactPwr\": -146.843,\n \"whDlvdCum\": 2230329.398,\n \"whRcvdCum\": 0.000,\n \"varhLagCum\": -583483.735,\n \"varhLeadCum\": 1456778.139,\n \"vahCum\": 4195596.420,\n \"rmsVoltage\": 237.049,\n \"rmsCurrent\": 1.026,\n \"pwrFactor\": 1.00,\n \"freqHz\": 50.12\n }\n ]\n }\n]",

If this can help you (from my Enphase app): Lifetime net energy production shoud be around 2.0 MWh Lifetime net energy consumption should be around 1.5 MWh

catsmanac commented 1 year ago

The raw data from the Envoy shows:

(Solar) lifetime production: 2696047.483 (House) lifetime consumption: 2230329.471 (Grid) net consumption: -458030.934

The net consumption is the ~difference between solar production and house consumption as expected, but one would expect any negative consumption to show up as positive net production. I wonder if we just hit another firmware version behavior as all data you are observing are actually coming from the Envoy.

Since you mention V0.0.17 was behaving differently,would you be able to open the webpage https://envoy/ivp/meters/readings and access the data v0.0.17 used? It will redirect you to the login page of the envoy, there you will need to get a token from the enlighten webpage and paste it in the token field.

lovelyday0 commented 1 year ago

yes V0.0.17 was reporting correct values for grid import and grid export. Here is was I got from https://envoy/ivp/meters/readings:

[
    {
        "eid": 704643328,
        "timestamp": 1695459354,
        "actEnergyDlvd": 2696890.906,
        "actEnergyRcvd": 1379.946,
        "apparentEnergy": 3055886.545,
        "reactEnergyLagg": 584430.416,
        "reactEnergyLead": 0.164,
        "instantaneousDemand": 902.888,
        "activePower": 902.888,
        "apparentPower": 906.984,
        "reactivePower": 105.113,
        "pwrFactor": 0.994,
        "voltage": 229.871,
        "current": 3.946,
        "freq": 50.125,
        "channels": [
            {
                "eid": 1778385169,
                "timestamp": 1695459354,
                "actEnergyDlvd": 2696890.906,
                "actEnergyRcvd": 1379.946,
                "apparentEnergy": 3055886.545,
                "reactEnergyLagg": 584430.416,
                "reactEnergyLead": 0.164,
                "instantaneousDemand": 902.888,
                "activePower": 902.888,
                "apparentPower": 906.984,
                "reactivePower": 105.113,
                "pwrFactor": 0.994,
                "voltage": 229.871,
                "current": 3.946,
                "freq": 50.125
            },
            {
                "eid": 1778385170,
                "timestamp": 1695459354,
                "actEnergyDlvd": 0.009,
                "actEnergyRcvd": 9615.608,
                "apparentEnergy": 2726.356,
                "reactEnergyLagg": 362.569,
                "reactEnergyLead": 1.105,
                "instantaneousDemand": -0.154,
                "activePower": -0.154,
                "apparentPower": 0.515,
                "reactivePower": 0.000,
                "pwrFactor": 0.000,
                "voltage": 4.029,
                "current": 0.128,
                "freq": 50.125
            },
            {
                "eid": 1778385171,
                "timestamp": 1695459354,
                "actEnergyDlvd": 0.001,
                "actEnergyRcvd": 15348.578,
                "apparentEnergy": 6200.627,
                "reactEnergyLagg": 361.641,
                "reactEnergyLead": 0.663,
                "instantaneousDemand": -0.537,
                "activePower": -0.537,
                "apparentPower": 1.180,
                "reactivePower": 0.197,
                "pwrFactor": 0.000,
                "voltage": 7.190,
                "current": 0.165,
                "freq": 50.125
            }
        ]
    },
    {
        "eid": 704643584,
        "timestamp": 1695459354,
        "actEnergyDlvd": 1539808.264,
        "actEnergyRcvd": 2001663.669,
        "apparentEnergy": 4196443.947,
        "reactEnergyLagg": 831.098,
        "reactEnergyLead": 1457062.527,
        "instantaneousDemand": -602.198,
        "activePower": -602.198,
        "apparentPower": 667.301,
        "reactivePower": -249.028,
        "pwrFactor": -0.764,
        "voltage": 229.943,
        "current": 2.891,
        "freq": 50.125,
        "channels": [
            {
                "eid": 1778385425,
                "timestamp": 1695459354,
                "actEnergyDlvd": 1539808.264,
                "actEnergyRcvd": 2001663.669,
                "apparentEnergy": 4196443.947,
                "reactEnergyLagg": 831.098,
                "reactEnergyLead": 1457062.527,
                "instantaneousDemand": -602.198,
                "activePower": -602.198,
                "apparentPower": 667.301,
                "reactivePower": -249.028,
                "pwrFactor": -0.764,
                "voltage": 229.943,
                "current": 2.891,
                "freq": 50.125
            },
            {
                "eid": 1778385426,
                "timestamp": 1695459354,
                "actEnergyDlvd": 761.928,
                "actEnergyRcvd": 0.000,
                "apparentEnergy": 4803.912,
                "reactEnergyLagg": 365.599,
                "reactEnergyLead": 0.332,
                "instantaneousDemand": 0.113,
                "activePower": 0.113,
                "apparentPower": 0.908,
                "reactivePower": -0.000,
                "pwrFactor": 0.000,
                "voltage": 4.943,
                "current": 0.183,
                "freq": 50.125
            },
            {
                "eid": 1778385427,
                "timestamp": 1695459354,
                "actEnergyDlvd": 0.009,
                "actEnergyRcvd": 4568.152,
                "apparentEnergy": 146.514,
                "reactEnergyLagg": 364.866,
                "reactEnergyLead": 0.926,
                "instantaneousDemand": -0.000,
                "activePower": -0.000,
                "apparentPower": 0.000,
                "reactivePower": -0.000,
                "pwrFactor": 0.000,
                "voltage": 4.860,
                "current": 0.000,
                "freq": 50.125
            }
        ]
    }
]
catsmanac commented 1 year ago

Thanks, that seems to confirm. These are the raw readings from the CT clamps and show both values. (The difference is indeed the -461.855 net consumption).

        "actEnergyDlvd": 1539808.264,    (net-consumption)
        "actEnergyRcvd": 2001663.669,    (net-production)

The meters report page has changed behavior with firmware D7.6.x as in D7.4.x it was still showing net consumption and production split bot in meters/readings and meters/reports. The result is showing the negative value for net-consumption. Probably means using meters/readings from v0.0.17 again. Need to look into it.

lovelyday0 commented 1 year ago

Yep, those values match my Enphase reports. So it was more than a renaming between v0.017 and v0.018, the source of data also changed. Indeed, it looks that, for my configuration at least, the readings from v0.017 are better. Thanks!

catsmanac commented 1 year ago

Yes, sources have changed as the meters/reports source has more data then the readings one, but looks like using that is a short lived dream.

catsmanac commented 1 year ago

A fix is available in the dev-test environment as version v0.0.19-beta1.

To install it add https://github.com/catsmanac/home_assistant_custom_envoy as HACS custom repository and download it

afbeelding

It should report net energy production and net energy consumption now the same way index_exportand index_import do in v0.0.17 for new firmwares (>=D7.6.x) as well.

Once tested successfully it will be published as v0.0.19

lovelyday0 commented 1 year ago

Hello @catsmanac, I have installed v0.0.19-beta1. It looks like lifetime net energy consumption and lifetime net energy production are now reporting the correct values. Thanks for the quick fix!

lovelyday0 commented 1 year ago

I just noticed that state_class for Lifetime Net Energy Consumption is total_increasing whereas state_class for Lifetime Net Energy Production is total. I don't know if this is an issue, but both counters are increasing so I would assume both to be total increasing

catsmanac commented 1 year ago

Hi @lovelyday0, good to hear it's now working again. As for the state-class, think you are right both should be total-increasing. I'll change it before final release as 0.0.19 in a couple of days. Thanks for letting me know. I'll let you know when it's published.

Any change I can talk you into opening https://envoy/ivp/meters/gridReading and https://envoy/ivp/meters/pvReading to see what these pages report? I have a plain vanilla Envoy Standard without CT and it was suggested these page may have similar data.

lovelyday0 commented 1 year ago

https://envoy/ivp/meters/gridReading

[
    {
        "channels": [
            {
                "phase": "L1",
                "activePower": 329.224,
                "reactivePower": -268.143,
                "voltage": 231.809,
                "current": 1.919,
                "freq": 50.125
            },
            {
                "phase": "L2",
                "activePower": -0.000,
                "reactivePower": 0.141,
                "voltage": 4.997,
                "current": 0.183,
                "freq": 50.125
            },
            {
                "phase": "L3",
                "activePower": -0.000,
                "reactivePower": -0.000,
                "voltage": 4.968,
                "current": 0.000,
                "freq": 50.125
            }
        ]
    }
]

https://envoy/ivp/meters/pvReading

[
    {
        "channels": [
            {
                "phase": "L1",
                "activePower": 0.000,
                "voltage": 231.728,
                "current": 0.470,
                "freq": 50.125
            },
            {
                "phase": "L2",
                "activePower": -0.149,
                "voltage": 4.030,
                "current": 0.128,
                "freq": 50.125
            },
            {
                "phase": "L3",
                "activePower": -0.684,
                "voltage": 7.190,
                "current": 0.162,
                "freq": 50.125
            }
        ]
    }
]
catsmanac commented 1 year ago

Thanks @lovelyday0

catsmanac commented 1 year ago

Hi @lovelyday0, v0.0.19 is now published. In HACS it will show under Enphase Envoy (Dev). Thanks for your help with this.

lovelyday0 commented 1 year ago

Thanks @catsmanac, I did update, everything seems OK