Hi everyone,
I’m reaching out because I’m completely stuck after doing some long-overdue cleanup on my Home Assistant instance. For reasons I still don’t understand, I suddenly ended up with over 43,000 entities in my setup, including nearly 4,000 lights and 4,000 media players. Needless to say, I don’t live in a shopping mall, and something was clearly wrong.
Initial situation
Before cleanup, these were the numbers I was seeing:
• Entities: 43,954
• Lights: 3,902
• Media Players: 3,918
• Sensors: 23,654
• Database size (home-assistant_v2.db): 1.3 GB
Performance had become sluggish, restarts were slow, and the UI felt increasingly unresponsive.
Cleanup with Spook
I installed the Spook integration by Frenck, which turned out to be an excellent tool. I used it to identify and remove orphaned entities — those that were no longer linked to any device or integration. The cleanup went smoothly, and the numbers returned to something much more reasonable:
• Entities: 1,612
• Lights: 56
• Media Players: 18
• Sensors: 608
These numbers now reflect what I actually have installed in my home.
Purging the database
To go a step further, I also used Spook to identify remaining orphaned entities in the database, and I manually triggered a purge with the following service call:
service: recorder.purge_entities
data:
keep_days: 0
repack: true
entity_globs:
- sensor.*
- media_player.*
This was intended to clear historical data related to those ghost entities and reduce database size.
The problem
It seemed like everything had worked — Home Assistant now boots up faster, the entity count is clean, and the UI is responsive again.
But the database? It actually grew in size.
[core-ssh ~]$ du -sh /config/home-assistant_v2.db
1.4G /config/home-assistant_v2.db
Even worse, now all of my charts are flat. No temperature history, no power usage, no pellet container levels — nothing. Even charts for today, which should be generating new data, show flat lines.
Here are some screenshots to show what I mean:
• Energy dashboard: completely flat and empty of all data !
• Room temperature history: blank
• Pellet container level: no variation, 64% filled, but look at the chart line
(All those graphs used to work fine before the cleanup.)
My questions
• What could have caused the charts to stop working, even for new data?
• Is there a way to “reactivate” or reset the recording for these entities?
• Should I manually delete the database and let HA recreate a fresh one?
• How can I safely clean up my system without losing current-day graphs?
Any insight would be hugely appreciated. I really want to keep my setup lean, but not at the cost of losing all visibility into what’s happening in my home.
Thanks in advance to anyone who can help, and special thanks to Frenck for building such a useful tool — even if I may have broken something along the way.
To be honest, keeping the historical data is “nice to have” without being crucial, so would deleting the db and restarting HA be enough to fix this issue ?
Thanks !