One of my major bugbears in Home Assistant (HASS) has always been that some integrations offer no proper way to completely delete a device or entity.
It seems so odd to me that in some cases there is no functionality beyond “disable”.
However, it’s not quite true that there’s no way to delete them… It is possible, but it can also go wrong.
Entities and devices are stored in configuration files in
core.entity_registry respectively). Depending on the type, they may also have an entry in
Below is the process to entirely remove a device and/or entity in Home Assistant.
Make sure you have a backup or snapshot of HASS from before you make these changes.
You can backup the entire machine it’s running on, snapshot the VM (if it’s on a VM), or take a snapshot in HASS’s backups section in the settings.
In general it’s not a good idea to modify these core files while HASS is running. Since they aren’t supposed to be user-modifiable, HASS doesn’t expect them to be changed by anything other than itself and therefore may not handle it nicely if they are changed while it’s running.
There are many ways to access HASS’s config while it’s not running, but the easiest way will be SSH in most cases.
- SSH to your HASS machine and move to your config directory.
If you’re running HASS in Docker, that will probably be
- Move to the
.storagedirectory and edit the following files with your choice of text editor.
- In each file, search for references to the name of the device or entity you want to remove.
- Delete the entire section for that object.
- Repeat steps 3 and 4 for each device or object you wish to remove from HASS.
Make sure you keep the syntax correct!
This is of the utmost importance. If you get this wrong, it will break.
If you’re unsure, paste the entire file into JSONLint, which will validate JSON syntax for you.
With all luck, HASS will start back up without a care in the world, just the way it shut down but without those pesky devices/entities you didn’t want!
Once it’s started, you should check the logs to ensure it’s not found any new problems in your configuration.
If something’s gone wrong and it doesn’t start up or starts up with a lot of errors, I suggest restoring from the backup or snapshot you took earlier and trying again.
I always welcome feedback on my posts, please contact me if you have any. I’m also happy to answer any related questions if I know the answer.