Correct wrongly entered sensor statistics

I track energy consumption by having an input number that I manually update once in a while by entering the reading of my electricity counter (in kWh). Then I sum up the accumulated consumption by making use of a sensor that I defined like this

name: "Electricity Cumulative Consumption"
    unit_of_measurement: kWh
    state_class: total_increasing
    device_class: energy
    state: "{{ states('input_number.electricity_counter') }}"

Unfortunately I made a mistake and entered a wrong value which messed up my statistics, as you can see here


What would be the best way to correct the value without having to manually modify the db? I tried using the statistics tab in the developer menu but nothing changed. Plus it seems there is a value every 15 minutes there even though I only update the sensor every few days… The counter not only affects the cumulative consumption but also the utility meter created by the Energy dashboard. I really hoped the modification would propagate

The energy dashboard does not create utility meter helpers?

The Energy dashboard just created a utility meter liked to the accumulated consumption, that’s it.
I just need to know if there’s a smart way to modify and propagate, otherwise I’d just try to change all the weird entries in the db manually, but that’s far from optimal

The energy dashboard does not create utility meter helpers. The only way to do that is by doing this:

I do really appreciate your help but I’m still struggling to understand how this is relevant for my problem :⁠-⁠)
I created an input number, then a template sensor to track accumulated consumption, then went into the Energy dashboard and added the accumulated consumption as source.

Now I just need to know what’s the easiest way to modify the mistake that I made, by entering the input number, and propagating to the other sensors.

The energy dashboard uses LTS (long term statistics). To remove an erroneous statistic previously recorded follow these instructions (first paragraph only):

You can edit the statistics in Dev tools>statistics

As I wrote in the initial post, and really the reason why I wrote here because I knew about the Statistics Tab and didn’t fix the error because this seem to be more complicated than that.

After having “fixed” the statistic sum the state value of the template sensor still had the same old value, as I checked going directly into the statistics table of the database.

So, when I updated the value correctly again after I noticed the error, I got a sum that is completely wrong

There is nothing helpful in the statistics tab. All the values are 0 (why?) and no spike is present at that time

Also the values of the tab are every 15 minutes…which I don’t understand given that the statistics table has 1 hour time resolution.
I think the problem is that those data are still in the states table and they have not yet be purged, but still it is puzzling to me why correcting the statistics would only affect the sum and not the state.

In the end the only solution that I found was to go manually into the DB and change the erroneous values.

Really a shame that Home Assistant does not offer an easier way to amend a typo into an input number.

1 Like