So what happened was I decided to delete some of my unused entitys from the statistics page, and now my energy dashboard has been completely cleared… I clearly removed something i shouldn’t and was wondering if theres any way to restore this or if i have to restore to my 2 month old backup? or atleast restore only those statistics from 2 months ago?(i have set automatic backup now, which i thought i did years ago…)
How did you do that? Just edit the page and put them back in. The data is still in the database.
Went to Developer tools - statistics and checked all sensors with “fix issues” and then clicked “delete all selected” and all is gone…
In years of using Home assistant, I don’t think I’ve ever looked at the Statistics tab…
So I did some experimenting.
There were two types of “Fix Issues” messages where I could delete anything. Not Recorded and No Data.
(If you see something else, please elucidate.)
No Longer Recorded are entities I have excluded from recording in the Recorder: component in the configuration.yaml file. Entities are automatically recorded by Home Assistant unless you tell it otherwise in Recorder:. I have 2858 entities, so you can appreciate that my database was approaching a terabyte of storage. In the recorder: component you can exclude a few entities or include a few to be recorded in the database. (It doesn’t make sense to do both). So, I just explicitly include about two dozen entities that I do want recorded. Everything else is then excluded. MY database (after a purge) went down to a more manageable few hundred Mb. In my example image, “Z-wave…” sensor is one of those entities excluded, no longer recorded. I clicked “Delete” and the statistics entry disappeared. But, looking in the States tab, the entity does still exist, so nothing is lost.
Entity has no state was interesting because this message appeared for every entity that I ever deleted. Mostly ESPHome devices that no longer exist. I would have expected that any statistic history for them would have been deleted when the entity were deleted. I was wrong. So, I deleted them as well.
All the others are entities I want a history from. As an experiment, I did delete one even though there was no “Fix Issue”. But the entity lives on and started collecting new data history,
So, to answer your original question. No. That’s what nightly backups are for.
Now, I have a question- Why would I need to use the Statistics tab? I’ve been using Home Assistant for five years and never looked at the Statistics tab.
I grouped by issues and checked everything. Thought I only checked the ones with issues, but I checked everything, clearly… I tried to remove statistics from a sensor to remove incorrect data and decided to “clean up” abit… and poof, all gone…
Since I never use statistics, I don’t see a downside to clearing the data. Am I missing a feature?
If you have no interest in looking back at usage statistics and such, there’s probably no downside to it. But I like to be able to see how the usage changes over time, especially after getting an EV. but I’ll just restore and lose the 2 months of data and be done with it. I’ve tried everything i could google, and give up!
I’m not certain that the data is gone from the recorder (database). I deleted all of my many, many entities that I really didn’t care about the statistics, and the database size didn’t change a bit.
Try a history graph and set the graph duration to one month. If the data is still there you will see it.
Yeah, Nah the data is goneski… But i have to give Home Assistant a shoutout, cus i backed up and restored back and fourth probably 20 times and made changes to files and tried multiple things. And the backups never corrupted.
So I restored it to the 2 month old backup, and just copy/paste the small changes that was made after. Which worked a treat!
And now you are looking at nightly backups…