Hey everyone!
I’m still pretty new to Home Assistant scripting, but I was getting really tired of manually cleaning up orphaned entities (somehow ended up with 1,746 of them! ).
With some help from Claude AI, I managed to put together a dashboard and scripts that make the cleanup process much less tedious. Thought I’d share in case anyone else is in the same boat!
What it does:
- Batch processing (25 or 50 entities at a time) instead of one-by-one
- Preview what will be deleted before actually removing anything
- Progress tracking so you know how much work is left
- Simple dashboard with buttons for each step
How I use it:
Scan Enhanced - See what orphaned entities exist
Preview Next - Review the next batch safely (no changes made)
Process 25 + Preview - Safe batch processing with auto-preview
Progress Report - Monitor cleanup progress
Force Refresh - Sync dashboard if needed
Nothing revolutionary, but it beats clicking through hundreds of individual entities!
Screenshots:
![Dashboard Screenshot]
The preview feature was super helpful - caught a few entities I actually wanted to keep.
Complete Code & Setup:
GitHub Gist with everything: To Gist
The Gist includes:
All 6 cleanup scripts
Dashboard YAML (with optional foldable workflow guide)
Required helpers configuration
Complete setup instructions
Prerequisites (Spook integration, optional frontend cards)
Quick Setup:
- Install Spook integration via HACS (required for orphaned entity detection)
- Add the scripts to your
scripts.yaml
- Add the helpers to
configuration.yaml
- Restart HA
- Add dashboard to Lovelace
Results:
Successfully cleaned up my 1,746+ orphaned entities with this system. The batch processing made it manageable, and the preview prevented any mistakes.
Optional extras:
The dashboard includes an optional foldable workflow guide if you install fold-entity-row
and template-entity-row
from HACS Frontend. But it works fine without these too!
Notes:
- Start with small batches (25) if you’re nervous about the process
- Use medium batches (50) for faster processing on large cleanups
- Always preview before processing if you’re unsure about any entities
- The dashboard shows live progress updates as you work
Still learning YAML scripting myself, so there might be better ways to do some of this. Open to any suggestions for improvements!
Hope someone finds this useful!
Credits:
Made with assistance from Claude AI - still figuring out HA automation myself, but this project turned out pretty well!
Update: If you try this out, let me know how it works for you! Always interested in feedback from the community.