home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.16k stars 29.84k forks source link

Enphase Envoy S Metered with CT and total-consumption not showing Net sensors #121781

Closed ruddj closed 1 month ago

ruddj commented 2 months ago

The problem

Good Day, I have a Enphase Envoy S with CT installed on single phase solar and 3 phase consumption but before the solar is connected, so Envoy is configured as "total-consumption".

In the IVP Meters it shows actEnergyDlvd and actEnergyRcvd but the integration does not show the Net sensors:

PyEnphase refers to the values as energy_delivered and energy_received

This appears to be because the sensors config file only defines them for CT_NET_CONSUMPTION_SENSORS and not for CONSUMPTION_SENSORS

Could these sensors please be added to the total-consumption meter type as well? Thank you

What version of Home Assistant Core has the issue?

core-2024.7.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

enphase_envoy

Link to integration documentation on our website

https://www.home-assistant.io/integrations/enphase_envoy/

Diagnostics information

config_entry-enphase_envoy-01J2G8EWC2085842AYRNR7DRDA.json

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 2 months ago

Hey there @bdraco, @cgarwood, @joostlek, @catsmanac, mind taking a look at this issue as it has been labeled with an integration (enphase_envoy) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `enphase_envoy` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign enphase_envoy` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


enphase_envoy documentation enphase_envoy source (message by IssueLinks)

catsmanac commented 2 months ago

HI @ruddj, always open to add more functionality. To fully understand what you are after let me share some information and ask some questions.

As for the questions part:

Reference schematic

afbeelding

ruddj commented 2 months ago

Thanks @catsmanac . Yes that diagram is correct. I have looked at the data a bit more closely (daytime now so have some active solar to compare to) and think I understand my misunderstanding. The ivp/meters/readings is showing more raw data, not the interpreted, so does not show the net value.

To more clearly explain my goal, as you suggest I want to get a Grid import/export based on the Enphase calculated values rather than using a templated Riemann sum, as this should be an actual value rather than interpreted between points in time.

It looks like the value I should be using for a base is the production.json consumption -> measurementType:"net-consumption" which appears to be the Envoy calculated Net values, based on the data it receives from the CTs. This value seems to update every second based on readingTime. However, reading through pyenphase docs and code I am unsure if these values are available in code.

Example Production showing total-consumption and net-consumption when solar is exporting to grid. Production-1057.json

As an aside do you consider it better to have the CTs as Net or Total location? I can ask the sparky to move it to the incoming wire the next time he is around. Originally I thought it would be better to completely separate load and generation as the Envoy can calculate it and it lets me see consumption clearly.

catsmanac commented 2 months ago

It looks like the value I should be using for a base is the production.json consumption -> measurementType:"net-consumption"

Pyenphase and Home Assistant only have the value in the raw section as it is the difference of sensor.envoy_123456789012_lifetime_energy_consumption and sensor.envoy_123456789012_lifetime_energy_consumption in Home Assistant. House consumption minus solar production for power and energy.

Values from your production.json.

         "measurementType":"total-consumption",
         "wNow":2230.512,
         "whLifetime":64625.784,

         "measurementType":"production",
         "wNow":2603.336,
         "whLifetime":22036.15,

         "measurementType":"net-consumption",
         "wNow":-371.116,
         "whLifetime":42589.631,

But these values are balanced as far as I know (see my data request below), the result of both grid import and export and will go up and down in time. If you want to use these with the energy dashboard you have to split the net-consumption value in an export and import one by detecting positive and negative value changes.

As an aside do you consider it better to have the CTs as Net or Total location

I cannot fully asses your local situation and local rules, regulations and practical limitations may apply, but generically speaking the Net location would be my preference as the data for the Total location is then calculated in the production report and this one does not need to be split in up/down as the house has only consumption. Your original thought is valid and its just that the Envoy does the same when the CT is in the Net location and brings use the additional data. And if you have access to data from a smart grid meter or alike it's even less of an issue.

Your configuration is not reported often, though probably used more often as I know. To refine my understanding of this situation and my models I would like to inspect a couple of hours of raw data for this setup. If you are willing, no obligation, can you provide a debug log with Enphase_envoy data? If so, in HA enable debug on the Enphase_Envoy, let it run for couple of 6-8 hours, preferably both covering solar production and no production, like mid-afternoon till mid evening, or simply for a whole day. Then disable the debug again and share the (zipped) log file.

ruddj commented 2 months ago

Thanks @catsmanac , Here is a debug log for a few hours in afternoon to evening (12:30-19:20) home-assistant_enphase_envoy_2024-07-15T09-19-49.379Z.log.zip

catsmanac commented 2 months ago

Thanks @ruddj, let me digest it. Had a quick look already and the data is a very nice set showing what is going on.

catsmanac commented 2 months ago

Think I have the pieces puzzled together for this situation with a total-consumption ct. Starting from the schema again.

afbeelding

The entity sensor.envoy_<serialno>_lifetime_energy_consumption is the value actEnergyRcvd - actEnergyDlvd of the Total-Consumption CT. Typically actEnergyDlvd for a Total-Consumption CT would not change and be zero or some small value it picked up during installation. In your case a fixed 207Wh.

The entity sensor.envoy_<serialno>_lifetime_energy_production is the value actEnergyDlvd of the Production CT.

The difference between these 2 entities (lifetime energy consumption - lifetime energy production) is the 'net consumption' or grid consumption. This value however will go down and up in the cause of the day depending on the actual solar production.

This is an example of it (corrected for their values at the start of the day to make it more clear) afbeelding

If the net-consumption is now split in 2 new entities for positive and negative changes it yields grid import and export. Below one is from such a calculation in excel afbeelding

So with a total-consumption CT you can calculate grid import and export from the available data. T

The alternative is to use the Production and Consumption power, you can find a description for that in the community. It might differ slightly from your situation but shows how to approach it. The methods described to split and calculate positive and negative changes can be applied to the above option as well. It's a good intro.

As an aside do you consider it better to have the CTs as Net or Total location

Guess by now you understand why my preference would be the net-consumption CT. But as said, if you local situation allows for it.

ruddj commented 1 month ago

Thank you very much @catsmanac . I'll look at trying to code in the difference between those lifetime energy values in HA. For Net Lifetime Energy Consumption I am using

{{
states('sensor.envoy_##_lifetime_energy_consumption')
| float(0) * 1000
-
states('sensor.envoy_##_lifetime_energy_production')
| float(0) * 1000 
}}

But I need to add some additional templates to calculate changes in this value. I'm looking at using Derivative sensors, but still testing options.

Thanks for your help with this and understanding how it all works.

catsmanac commented 1 month ago

@home-assistant close