Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Which Sensor shows the energy send to the grid? #195

Open
superpower10 opened this issue May 3, 2024 · 28 comments
Open

Question: Which Sensor shows the energy send to the grid? #195

superpower10 opened this issue May 3, 2024 · 28 comments

Comments

@superpower10
Copy link

Could it be that there is no entity for the energy that is send to the grid?

Or I‘m i blind? Or do I need two entities and then calculate it, if so which?

Thanks

@catsmanac
Copy link
Collaborator

catsmanac commented May 3, 2024

Hi @superpower10, probably as always, it depends. If you have an Envoy Metered with installed current transformers (CT) it should be there. If no ct meters installed and configured or an Envoy S non-metered then you won't find them.

Look for Envoy <sn> Lifetime Net Energy Production for export to grid and Envoy <sn> Lifetime Net Energy consumption for import from grid.

@superpower10
Copy link
Author

Thanks. These are the ones I was looking for.

@superpower10
Copy link
Author

@catsmanac Sadly that aint‘t it.

It can‘t be that I produce Solar-Power at night and send it to the grid
IMG_0909
IMG_0910

And Enlighten tells me that I‘m right. The values are totally different:
IMG_0908

@superpower10 superpower10 reopened this May 4, 2024
@catsmanac
Copy link
Collaborator

To deduct what is causing this, can you:

  • Explain what type Envoy and features you have. Looks like Envoy metered with CT and battery
  • Upload the diagnostics file here so we can see what the integration detected and what the Envoy is reporting. (Settings - Integrations & Devices - Enphase - ⋮ Menu - Download Diagnostics)
  • How did you calculate today's values from lifetime, using a utility meter?

@superpower10
Copy link
Author

superpower10 commented May 4, 2024

I have:

  • Envoy-S-Metered-EU Gateway with CTs
  • 10,5 kW Battery
  • 12,4 kWp Panels

Calculation:

  • Done by Home Assistant by Utility Meter Helper (Reset every day, no Delta Values) with the Entity mentioned from @catsmanac

Diagnostics:
config_entry-enphase_envoy-778582829baebb651059ac99a0034c54.json

@catsmanac
Copy link
Collaborator

Checking the diagnostics file, the lifetime net energy production and lifetime net energy consumption (Grid export and Grid import) have values reported by the Envoy as actEnergyRcvd and actEnergyDlvd

"entity_id": "sensor.envoy_<serial>_lifetime_net_energy_production",
"state": "2378475",
"last_changed": "2024-05-04T10:59:57.579246+00:00",

"entity_id": "sensor.envoy_<serial>_lifetime_net_energy_consumption",
"state": "4322971",
"last_changed": "2024-05-04T10:37:04.175894+00:00",

"Endpoint-meters-readings":  ... "actEnergyDlvd\": 4322971.567,\n  ...   \"actEnergyRcvd\": 2378475.181

To validate the numbers you can configure the Energy dashboard in HA, if not done yet. For Solar use Envoy Lifetitime energy production

afbeelding

For Electricity Grid use sensor.envoy_serial_lifetime_net_energy_consumption for Grid Consumption and sensor.envoy_serial_lifetime_net_energy_production for Return to Grid

afbeelding

The dashboard will need couple of hours or even till next day to start showing numbers. The battery charge/discharge difference will be included in the house consumption. This will allows checking numbers.

Other alternative is look at history data of sensor.envoy_lifetime_net_energy_production and sensor.envoy_lifetime_net_energy_consumption and check start/end values for some days to compare to Enlighten.

@superpower10
Copy link
Author

superpower10 commented May 4, 2024

@catsmanac
I did this already yesterday and numbers are not even close to be correct:
IMG_0911
IMG_0913

IMG_0912

@Hoffmann77
Copy link

Had the same issue some time ago and did some investigation. If I remember correctly the issue originates from the battery storage. The gateway counts all the energy returned to the grid and all the energy consumed from the grid. If the batteries are installed on the same phase and you consume energy on another phase, the gateway detects the required energy and discharges the energy from the battery to the grid. Your meter measures the balance between import and export and thereby shows zero. Unfortunately the gateway uses a different way and counts all the energy exported.

@catsmanac
Copy link
Collaborator

This issue is also reported by @fwolf222 for the HA Core Enphase integration.

@Hoffmann77, you are describing difference in behavior between the Smart meter and the Envoy I think?

@superpower10, your issue is the difference between the Envoy and the Enlighten web-site I think? Just that I'm not mistaking, your last 2 pictures, which one is the HA one (first one?) and which is the Enlighten App picture (second one?)? I see both have battery data, where is that sourced from?

Can we agree that the lifetime production reported from production CT matches 41 <-> 42,4 is close and small difference is probably caused by Enlightens cloud 15 min upload interval? Check if/how close they are when no production is happening anymore.

@Hoffmann77
Copy link

I want to say that the Net consumption CT represents the "Netto bezogen" bzw. "Netto eingespeist" values. Net consumption only relates to grid imported/exported if you don't have a battery installed (Don't know if this is only the case in germany).

@superpower10
Copy link
Author

superpower10 commented May 5, 2024

@catsmanac, the first two are from Home Assistant which are not correct. The last one is from the enlighten App.

The solar production value is correct.

The information from and to the grid is wrong.

The App says I used 0,3 kW from the grid and exported 20,8 kW to the grid.

The Net Energy Consumption says 10,6 kW (way more than the App and is not realistic). The Net Energy Production says 30,4 kW.

So both values are off by round about 10 kW.

Maybe @Hoffmann77 is right and the battery is the "problem"

@catsmanac
Copy link
Collaborator

I double checked the code again and net production and net consumption is reported from the net consumption CT Meter readings report. One would expect that reports what actually passes through the 3 CT and sums it.

Would this be a configuration setting of the Envoy where it corrects the CT values based on other data? I assume the battery is connected to the switchboard and the consumption CT measures between the grid and the switchboard, is it?

Looking for the offset of 10, it's really close the battery aufgeladen value. That energy kind of disappeared into the battery and the Envoy probably knows it from battery data. Would it add that to the grid import? Just thinking out load here. On the other hand the 4.7 entladen is energy that 'magically appears' and doesn't seem to relate the offset of 10.

Is it a miscalculation in HA? The values in Netz should be the change in the net consumption and net production over the day.

@superpower10, you mentioned there is hardly any grid import, yet HA shows 10. In history does that import growth happen through the day, matches when the battery loads or something like it. Might give a correction option to use.

As you probably guessed from all this, it's a puzzle. Maybe the battery is the "problem" indeed, but it would be neat if we can find a way around it.

Both picture side-by-side for my notes, left HA. If the battery values of HA come from the integration than those numbers are relatively good as they are based on change in SOC of the battery.
afbeelding

@Hoffmann77
Copy link

screenshot

This screenshot shows the issue. This describes the situation for my type of installation in Germany.

My batteries are installed on phase 1. If I now consume energy on phase 2 at around 1:24 there is no physical way for the energy to get from phase 1 to phase 2. So you cannot consume the energy from the battery directly. But there is a trick called "Saldierender Zähler". This meter allows to sum up the energy on all three phases. So if I export 2500 watts on phase 1 and import 2500 watts on phase 2 the meter counts zero. The meter on the Enphase gateway works a different way. It counts 2500 watts on phase 1 for the export value and it also counts 2500 watts for the import value. So both values "Lifetime grid import" and "Lifetime grid export" are increased, resulting in these strange values. If you sum up both values you get 0 again. So with these meter values you can get the net "Netto" import/export.

Luckily Enphase also provides the active power of the meter which is the summed power of the meter. This values works as "Summierender Zähler" so you can use a Rieman sum integral to get the same values as shown in the Enphase app and on your energy meter.

Another explanation about the types of meters in German: saldierende-vs-phasenbezogene-zaehler-erklaert

@Hoffmann77
Copy link

@superpower10 could you provide two new screenshots? One from home assistant as before and one from the Enphase app "Energie" tab. There you can see the value the home assistant values correspond to.

@catsmanac
Copy link
Collaborator

Ah right, thanks for the explanation. Same here in the Netherlands, the DSMR smart meter will also balance the phases like you describe. (I have no batteries nor CT, so don't have the issue).

So you use the net consumption power and split in import/export when positive or negative and these into Riemann? Or just single one?

@superpower10
Copy link
Author

@Hoffmann77, here are the screenshots you wanted. First is Home Assistant, second from the Enlighten App Energy Tab. Both are from today:
IMG_0914
IMG_0915

@catsmanac
Copy link
Collaborator

Would be nice if the 'Saldierender Zähler' mode is a configurable option on the Envoy metered. Now the consumption CT is next to useless it seems. Well for HA that is, probably not for Enlighten.

To find some alternative we need to check if we can use the values in /production calculated by Envoy. In HA there's Todays energy consumption, last 7 days energy consumption and lifetime energy consumption. That is consumption by the house. Does todays energy consumption, or the change in 7 day or lifetime energy consumption match the Enphase House consumption?

@Hoffmann77
Copy link

Ah right, thanks for the explanation. Same here in the Netherlands, the DSMR smart meter will also balance the phases like you describe. (I have no batteries nor CT, so don't have the issue).

So you use the net consumption power and split in import/export when positive or negative and these into Riemann? Or just single one?

I am splitting up the power into import and export.

@gateway_property(required_endpoint="ivp/meters/readings")
def grid_import(self):
    """Return grid import."""
    if eid := self.net_consumption_meter:
        power = JsonDescriptor.resolve(
            f"$.[?(@.eid=={eid})].activePower",
            self.data.get("ivp/meters/readings", {})
        )
        if isinstance(power, (int, float)):
            return power if power > 0 else 0

    return None

@gateway_property(required_endpoint="ivp/meters/readings")
def grid_export(self):
    """Return grid export."""
    if eid := self.net_consumption_meter:
        power = JsonDescriptor.resolve(
            f"$.[?(@.eid=={eid})].activePower",
            self.data.get("ivp/meters/readings", {})
        )
        if isinstance(power, (int, float)):
            return (power * -1) if power < 0 else 0

    return None

@Hoffmann77
Copy link

@superpower10 If you subtract the home-assistant grid import from the grid export you get the "Netto Eingespeist" value from the Enphase app.

@Hoffmann77
Copy link

Would be nice if the 'Saldierender Zähler' mode is a configurable option on the Envoy metered. Now the consumption CT is next to useless it seems. Well for HA that is, probably not for Enlighten.

To find some alternative we need to check if we can use the values in /production calculated by Envoy. In HA there's Todays energy consumption, last 7 days energy consumption and lifetime energy consumption. That is consumption by the house. Does todays energy consumption, or the change in 7 day or lifetime energy consumption match the Enphase House consumption?

I think there actually was another type of meter called "total-consumption". Saw it somewhere in an issue here.
I don't have access to home-assistant the next days but from what I remember the consumption values are correct but include energy from the batteries. So if there batteries where charged the charged energy is included in the house consumption value.

@catsmanac
Copy link
Collaborator

catsmanac commented May 7, 2024

I am splitting up the power into import and export.

I assume you are getting it faster then 1/minute. Activepower you are getting is the current net power consumption entity which is default only 1/minute.

@catsmanac
Copy link
Collaborator

I think there actually was another type of meter called "total-consumption".

Yes there is, calculated by the Envoy from what sources it has. Entities are named today/last 7 day/lifetime energy consumption and are the total/house consumption. Was kind of hoping that Envoy got these right but sounds as if these will be same amount too high.

@superpower10
Copy link
Author

superpower10 commented May 7, 2024

@superpower10 If you subtract the home-assistant grid import from the grid export you get the "Netto Eingespeist" value from the Enphase app.

Yes, it does. At least today.

Will look again later and tomorrow.

@superpower10
Copy link
Author

@superpower10 If you subtract the home-assistant grid import from the grid export you get the "Netto Eingespeist" value from the Enphase app.

Yes, it does. At least today.

Will look again later and tomorrow.

Today it doesn’t. They are off by at least 1 kW

@Hoffmann77
Copy link

I am splitting up the power into import and export.

I assume you are getting it faster then 1/minute. Activepower you are getting is the current net power consumption entity which is default only 1/minute.

I am currently using an update interval of 20 seconds. Did a quick comparison and at the end of each the full day the values get in the range of 1 kWh difference.

@Hoffmann77
Copy link

@superpower10 If you subtract the home-assistant grid import from the grid export you get the "Netto Eingespeist" value from the Enphase app.

Yes, it does. At least today.
Will look again later and tomorrow.

Today it doesn’t. They are off by at least 1 kW

This could be a synchronization issue. The Enphase app only updates every 15 minutes, so maybe that's reason where the difference comes from.

@zittel05
Copy link

@Hoffmann77, I have the same issue here, import and export to the grid are both too high by the same amount.
How/where did you include the code above for splitting up the power into import and export and how should I configure the energy dasboard later on?
Thanks.

@Hoffmann77
Copy link

@Hoffmann77, I have the same issue here, import and export to the grid are both too high by the same amount. How/where did you include the code above for splitting up the power into import and export and how should I configure the energy dasboard later on? Thanks.

The code above is from another integration.
You could try the code below for this integration. It's only a quick draft so no guarantee that it works.

If it works you need to add Riemann sum helpers for the new sensors. You have to use these Riemann sum sensors in the energy dashboard.

Add the following to "const.py" after line 86.

SensorEntityDescription(
    key="grid_import",
    name="Grid import power",
    native_unit_of_measurement=UnitOfPower.WATT,
    state_class=SensorStateClass.MEASUREMENT,
    device_class=SensorDeviceClass.POWER,
),
SensorEntityDescription(
    key="grid_export",
    name="Grid export power",
    native_unit_of_measurement=UnitOfPower.WATT,
    state_class=SensorStateClass.MEASUREMENT,
    device_class=SensorDeviceClass.POWER,
),

Add the following to "envoy_reader.py" after line 868.

async def grid_import(self,phase=None):
    """Report cumulative or phase Power consumption (to/from grid) from consumption CT meters report"""
    jsondata = await self._meters_readings_value("activePower",report="net-consumption",phase=phase)
    if jsondata is None:
        return self.message_consumption_not_available if phase is None else None
    return int(jsondata) if int(jsondata) > 0 else 0

async def grid_export(self,phase=None):
    """Report cumulative or phase Power consumption (to/from grid) from consumption CT meters report"""
    jsondata = await self._meters_readings_value("activePower",report="net-consumption",phase=phase)
    if jsondata is None:
        return self.message_consumption_not_available if phase is None else None
    return (int(jsondata) * -1) if int(jsondata) < 0 else 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants