Clear all statistics

Hello,
is it possible to delete all statistics at once?
I would like to start with a “clean” database from January 1st.
But I have relatively little desire to edit all the entities individually.
Is there a tool/add-on to reset the entities?

Thank you in advance

Hi i-B4se,
Welcome to the Home Assistant Forum!

If you delete these files and restart Home Assistant ALL the history is gone, and it will rebuild.
I do it about once a year myself. It won’t effect devices, entities, automations, or any of that. Just the stored history of what happened.

BE SURE TO DO A FULL BACKUP FIRST IN CASE SOMETHING BAD HAPPENS OR YOU DON’T LIKE THE RESULTS… YOU HAVE BEEN WARNED

image

1 Like

FYI, it’s just that first file, home-assistant_v2.db, which contains the statistics, along with all events and state changes. If you delete that, all those will be gone, along with the long-term statistics. HA will create a new database and start populating that.

The .log file gets created each time you start HA, so no need to delete that. In fact the .log.1 file is the old .log file, renamed before the new one is created. Those, as the name suggests, are just logs of things happening in the system, not historical data from sensors and entities.

Finally, the .log.fault is exactly what it sounds like.

Somewhere there’s an FR or at least a discussion about offering a way to purge long-term statistics, similar to what we can do now with the events and state changes using the Recorder: Purge action. I haven’t seen any movement on that, however.

1 Like

@Sir_Goodenough & @CaptTom
Thank you for your answers.
The other two files are not relevant, are they?
image

Those are temporary files SQLite uses while working with the database. I suspect they hold the data to be written to the database on the interval defined by the commit_interval: in configuration.yaml, among other things.

1 Like

When answering questions like this I find it easier to suggest deleting them all and not bother explaining in several posts what they all do because in the end it does not matter.
You probably don’t have to restart, either, but likely a best practice.

I do appreciate the explanation for the OP, however.