Correct Envoy lifetime production energy

Blueprint

This blueprint will calculate a corrected solar production value for the enphase_envoy integration aggregated envoy or individual inverter solar production value. The envoy firmware calculates inverter production data in a 32 bit value which will reset to zero when reaching 1.193 MWh.
This 1.193 MWh is the (rounded) equivalent of 4294967296 Joule which is the maximum value that can be stored in a 32 bit integer. Due to this limit a single inverter value will drop to zero when this value is reached. Also the aggregated value of all inverters will get a drop of 1.193 MWh at the moment any inverter reaches this value.
So both aggregated and individual inverter data drops with this value. This blueprint will detect these resets and account for it in a corrected value. It will also recognize if these drops are repaired and increase with same amount.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Implement one for the Envoy aggregated solar production, and if tracking individual inverter production data, one for each of enabled inverters in the enphase_envoy integration.

This blueprint requires the home assistant Uptime integration to be installed and a template sensor for it be created and passed to the blueprint. This uptime sensor is used to detect Home Assistant restarts and avoid long delays before detecting value changes in the production sensors after HA restart.

Template

In your template configuration yaml file add one template like below for each envoy solar production entity to correct.

This example adds a new sensor named sensor.envoy_123456789012_lifetime_energy_production_corrected which is tracking sensor.envoy_123456789012_lifetime_energy_production and calculates a corrected value for overflows.

- use_blueprint:
    path: marcelhoogantink/correct_envoy_livetime_production_energy.yaml
    input:
      # entity-id of original sensor to be corrected
      envoy_entity: sensor.envoy_123456789012_lifetime_energy_production
      # uptime in seconds
      uptime: sensor.envoy_ha_uptime
      # uom for target
      uom: MWh
  # friendly name of the new sensor for correction
  name: Envoy 123456789012 lifetime energy production corrected
  # unique_id of the new sensor for correction
  unique_id: envoy_123456789012_lifetime_energy_production_corrected

Uptime

In your template configuration yaml file add one template like below for the uptime sensor to pass to each blueprint created.

- sensor:
  - name: Envoy HA Uptime
    # this sensor needs the Update integration 
    # (https://www.home-assistant.io/integrations/uptime/)
    # and updates every minute as now() changes every minute by default
    unique_id: envoy_ha_uptime
    state: >
      {{ (as_timestamp(now()) - as_timestamp(states('sensor.uptime')))|int }}
    unit_of_measurement: 's'
    device_class: duration
    state_class: measurement

More information on the development of this blueprint can de found here:

Is this blueprint any different from what a Utility meter helper would do if you do not set a reset cycle?

Would utility meter handle step downs like below?

No, it does not. But it can turn a e.g. a daily total in an ever increasing one.

I have no clue what such a step down means so if your sensors do that they are pretty useless. If a step down is both the sensor dropping some data and adding some new in the process, there is no way you can infer anything from that. This is also not behaviour caused by the limits of 32 bits. It seems do fundamentally broken you cannot do anything with it. My guess is that there is something else entirely going wrong here.

It looks like a statistics sensor that has data dropping out of its calculation window.

My total yield is not yet at your range 8MWh) but has not misbehaved yet. If it does, I’ll use the daily sensor in a utility meter to fix it.

Data as shown in the picture is directly from the Envoy (physical) device. The envoy reports aggregated lifetime solar production by summing reported values from individual inverters.

These inverters sum in production in joules. 32 bit max=4294967296 joule => 4294967296 / 3600 = 1193046 => wH = 1193.046 KwH => 1.193046 MWh.

So when the solar panel has produced 1.193 MWh in it’s life, with current firmware, the value overflows and starts at zero. The Envoy shows this in a sudden drop of value with that amount in the aggregated value.

In my solar installation the aggregated value is at 25.1 MWh for 24 panels and lifetime of 2.5 years. With all individual panels now between 0.9 and 1.14 MWh. Not at overflow point yet, but moving towards it.

Many others reported these steps and experienced this phenomena already.

The drop with this 1.193 amount and some added new production during the 15 min reporting cycle of the Envoy is pretty recognizable. Any (small) drop implies the issue already as production should only increase. Divide the drop by 1.193 MWh and the ceiling is count of panels that dropped in the polling period.

The utility meter can indeed be used for this by creating a daily one for each individual inverter and summing these. Not all Envoy firmware versions offer individual inverter energy production, so this is an alternative.

Not sure how daily utility meter on the aggregated value would handle these drops.

HA has many methods to deal with issues, one of it strong points. With this issue, most important is to prepare now, rather then late as any new sensor created will not have stats for the Energy dashboard to look back in time.

For use with the energy dashboard specifically, one can correct the original lifetime production statistics outlier using the developer tools / statistics and correct the value at the moment of a drop. That will not correct the entity value, but allow correct energy calculations.

nice code, perhaps it s will good to regroup all code , adblue on a enphase enrgy topic, to have all information in one topic :slight_smile:

We are working on updating the ha enphase envoy doc to refer to these blueprints. This one is now linked to from the issue description in the docs.

Hey,

This is also happening to my Envoy system. Went from 18MWh lifetime production to 7MWh in a couple of months, is there any way to fix the envoy_122148009146_lifetime_energy_production data? Or only fixing the statistics for the energy dashboard?

Not a simple method I know off (which doesn’t mean there isn’t one).

Fixing the statistic outliers on the lifetime values will make the energy dashboard look normal again.

Option I’m considering, is implementing the correction blueprint, then export the original lifetime data, correct it, and import statistics dated before correction creation using spook import statistics. Haven’t tried it yet, so can’t say how cumbersome or if it even will work.