How to remove entities without a unique_id? Where are they?

I have several entities withouta unique_id that I created when making some tests but that I cannot delete from the UI, there is no delete button.

image

When adding a unique_id during creation (via MQTT discovery), I have a better control of it though the UI, but still not possible to delete it - the delete button is grayed out

There are already numerous questions such as this one, but no answer (except mentioning known_devices.yaml that I do not have):

(etc.)

In one of them, @tom_l mentioned

You can’t. You can only disable them

My question: is there indeed NO WAY to delete entities in Home Assistant? They must be stored somewhere!

I managed to find the second entity in core.entity_registry

1 Like

If it is an MQTT sensor all you have to do is send a blank retained message to the discovery topic.

Or use MQTT Explorer to delete the retained discovery topic.

1 Like

Yes, for the MQTT entity this is possible (and I found it in one of the stores). It is still mysterious for the ones without unique ID.

Has anyone figured out how to assign a unique ID so they can be managed in the UI?

1 Like

@WoJWoJ - Were you ever able to find an answer to this?

Unfortunately not.

The only solution I found for this was to modify the home-assistant_v2.db with SQLite DB Browser, which you can download and install for free. I am running home assistant in a docker instance on a Ubuntu server. The database file is found in the home assistant config folder.

*** Messing with the database is probably the best way to completely screw up your entire install if something goes wrong - so make a backup first. ***

Stop home assistant and make a backup of the database first. Then while home assistant is stopped, you can access the database with the SQLite DB Browser. For me, my orphan entities were caused by creating MQTT sensors in my configuration.yaml. I found these entities referenced in the “states” table of the database. I simply deleted every record I found which referenced the orphaned entities. Once I restarted home assistant, I checked the entities and found the orphan entities were all gone.

I had previously tried restarting home assistant to see if they would disappear, that did not work. I used grep to find any instances of the orphaned entities in the .storage folder. I removed every instance I found in that folder to only see them created by home assistant again. The only file left with references to the entities I wanted to remove was the database file. I found these things so annoying I was willing to risk a complete re-install and re-build if something went wrong in the database modifications. But hey, if it did go that wrong, a clean install would also fix the issue. :slight_smile:

4 Likes

If what is in home-assistant_v2.db is causing the entities to show up, most likely you simply need to wait until the recorder history is purged from the database to get rid of it. 10 days is the default setting for that. Then the last values from the old sensor are deleted automatically.

If not want to wait, from developer-tools/service and “Recorder: Purge Entities” I was able clear my orphan entity.

31 Likes

This worked for me… thanks again.

I have also have an entity, created from HACS, that I cannot remove. Interestingly the entity is not displayed when I goto settings > devices > entities but is offered as an entity when adding to lovelace. The entity has not been used for many months. I ran recorder purge for it. Still there.
How can I remove it and isn’t this an inconsistency in the database? Is there possibly a service to check this and clean it?

Thanks Bogey.

This did not work for me however. Any suggestions?

FYI: I run HA on top a deconz system. Deleting the troublesome entities from deconz, reloading (from deconz), deconz:deleting orphans and recorder:purging still leaves the ghost entities :confused:

I have a lot of (maybe 30000?) sensor ble entities without unique id and with not (anymore) existing mac adresses. Recorder Purge entities does not delete them. I would be glad if anyone had an idea …
Many Thanks, Michael

Just tried to watch the Database (home-assistant_v2.db) with SQlite DB Browser. Can’t find the unused entries in “state” folder, but they are all listed under “event_data”. Can I delete them from there and might it help?

Damn I have exactly the same problems! Any solution for it. With Recorder: Purge Entities it doesnt work.

PS:
Clear the browser cache works!

3 Likes

Hi ,

Yes it helped , log out/log in removed the ones.

Thanks

3 Likes

After purging the entity, log out/log in will make it go away.

Thanks guys.

2 Likes

The question still remains; “How do you purge an entry that does not appear in the list of entities or when typed out?”

For me I went to “Developer Tools”, “Statistics” tab, then clicked “Fix Issue” on all the entities without unique ID’s.

4 Likes

Thanks a lot,
I just had to clear the cache

1 Like