How to delete old Energy Data

I spent almost two days solving this problem because I mixed W with kWh. Tried to tinker with the database but as you say, deleting all values from entity_id is not enough. It is saved also in statitistics. Then it looks like that some data are linked with the power sensor that is later used for energy sensor by the integration function and later into utility meter. The final solution for me was to simply restore the database from backup and HA as well. Yes I lost some data but at least I dont have corrupted data.

Anyone else here with a solution for this? I’ve deleted 3 days from the database with corrupted data, but the problem is it just aggregates the wrong values back again. So frustrating.

Even if I delete that entry, it will reappear.

Look here, worked for me.
How to completely wipe sensor history? - Development - Home Assistant Community (home-assistant.io)

1 Like

Hi, i have the same issues after upgrading to the latest of 2022 and also the newest in 2023. I am able to play around in the DB an change some fields and the values do seem half ok then, but even when looking at the sensors, smart meter the problems keep getting back. I started using Home assistant next to homey for the energy monitoring, but this is just too troublesome. I do like the interface and dashboards, but I already do not trust the numbers anymore. As I am no developer or want to keep on spending time in the DB and frustration in this, why can this not be solved? I read threat threats going back to when the energy dashboards where released and everywhere you hav to dig into deep DB commands and changes. I want to simply with one click, reset all numbers from all energy sensors and start over. anyone knows where this is requested to the developers?

4 Likes

Hi,
I’ve been using the energy dashboard for about 6 months and have got some great data from my solar installation, my heat pump and the corresponding usage from the grid.
I’ve recently created some utility meters to track the costs from grid usage during the 3 different tariffs we have here in Spain.
It is working great but I want to stop the direct inclusion of my Shelly EM, but I’m greedy because I don’t want to lose my historical data (like everyone else). The solution of changing one of my new meters to the direct Shelly unique_id isn’t an option because the feeds from the Utility Meters don’t have unique_ID’s. I’m also using the Shelly as a source for the Utility Meters.
Anyone got any ideas?

1 Like

Editing the database is no longer the way to do this.

Go to Developer Tools → Statistics and click on the ramp icon next to the entity.

1 Like

This does not work for me. I have a huge spike at one day. But looking into the statistics at that day; I cannot find any entity, das hat abnormal values. I suppose, there is another logic, that I do not find.

In the statistic you see the data so are you sure about the right date and time?
Have you checked the day before the spike, some times it can come from the day before, verify every value.

@jeedee : Thanks for your questions. Yes, I have checked the 1st of July and the 30th of June 2023. I have looked at the statistics of all sensors of my PV system, especially the sensors for the battery, which seem to cause the spike:

It would be nice, if my battery had a capacity of 3.1 MWh :slight_smile: .

Also following this since I have the same issue with costs… did a wrong calculation with my “total_electricity_price_including_vat” (a template sensor), and for like 2 hours it thinks I paid €80 per kWh hehe.

Not a super big deal, but would be nice to fix it. :slight_smile: