Help me correct my utility_meter value

Yesterday I found out that my current clamps of the Shelly3EM were installed wrong, and I reversed them. That led to some other changes, especially the value of the total harvasted kWh.

- platform: template
  sensors:
    shelly_pv_harvest_energy:
      friendly_name: "PV Ertrag Gesamt"
      device_class: energy
      unit_of_measurement: "kWh"
      value_template: "{{ ((states('sensor.3em_pv_channel_a_energy')|float + states('sensor.3em_pv_channel_b_energy')|float + states('sensor.3em_pv_channel_c_energy')|float))|round(2) }}"
      availability_template: "{{ not ( is_state('sensor.3em_pv_channel_a_energy', 'unavailable') or is_state('sensor.3em_pv_channel_b_energy', 'unavailable') or is_state('sensor.3em_pv_channel_c_energy', 'unavailable') ) }}"

In this sensor all 3 states had to be changed from states('sensor.3em_pv_channel_a_energy_returned) to states('sensor.3em_pv_channel_a_energy).
The sensor had a value of 9.993,3 before = total kWh harvested. After the change it was ZERO of course.

This lead to this stupidly wrong statistics:

I tried going to developer tools → statistics, find the sensor.pv_erstrag_[daily, monthly, yearly] and delete the wrong value at Jan-15th 13:35, and set it to the correct value.

But it stills shows that way:

Daily is correct now of course, but I can wait one year for the yearly one to be correct again:

Who can help my solve this issues please?

That’s not statistics, it’s state history. It will be gone in 10 days (default).

Or you could use the utility_meter.calibrate service to correct it.

https://www.home-assistant.io/integrations/utility_meter/#services

You can run the service in Developer Tools → Services.

Thanks Tom. Of course. My bad. I set the utility_sensor’s state to a new value, but had to use the utility_meter.calibrate service of course. Did that years before sucessfully, and totally forgot about it :wink:

And what now remains is “only” that state history that will IDLE OUT automatically anyway. So just annoying to see, but totally correct as this shows the state at a give time (and CAN’T be altered at all). Correct?

It depends how good you are with SQL to manipulate the database directly. Personally I don’t have a clue. Especially with the recent table optimisations.