Repair of energy database

Yesterday I purged my whole database with 0 days remaining. After that my energy dashboard is broken as you can see here:

image

I searched the database file for the sensor id and found out that it just started from zero in the summary for this sensor:

Can I somehow fix it? Deleting these values just shift the time of the negative values. Maybe I need to summarize all by myself again?

Or do I need to restore a backup of my installation and therefore loosing recent data but having a good energy dashboard?

1 Like

I updated all the “sum” fields by hand right now and will wait for the next regular updated of the statistics to see if it starts again from zero or will work properly again from now on.

Yesterday:

UPDATE "statistics" SET sum ="677.48" where metadata_id = 109 and created = "2021-12-11 09:00:10.224829"
UPDATE "statistics" SET sum ="677.64" where metadata_id = 109 and created = "2021-12-11 10:00:10.263662"
UPDATE "statistics" SET sum ="677.76" where metadata_id = 109 and created = "2021-12-11 11:00:10.221105"
...
UPDATE "statistics" SET sum ="681.63" where metadata_id = 109 and created = "2021-12-12 12:00:10.247542"
UPDATE "statistics" SET sum ="681.8" where metadata_id = 109 and created = "2021-12-12 13:00:10.289291"
UPDATE "statistics" SET sum ="681.96" where metadata_id = 109 and created = "2021-12-12 14:15:27.281301"

Edit:

Once again it started again counting from zero and again my energy dashboard is ripped:

Any ideas?

I have same problem, but I don’t think you can do it at all manually…
I have situation where STATE is growing and SUM as well, but 6 records (twice) had value 0, but SUM was then increased for entire value of STATE, so with 2 errors I can see I generated 3x more energy than in reality… Not sure how to fix if without some script which will repair each record of SUM.

Seems like you also have to fix statistics_short_term table to have it fixed.