How are entities managed in .storage/core.entity_registry?

I had the Netatmo integration installed and an area called “Paris” set up.
It generated, among others, sensor.paris_temperature.

I then removed this integration; it disappeared from the HA page. So far, so good.

I then installed the integration again, and configured “Paris” again.
It generated, among others, sensor.paris_temperature_2.

I wanted to change it to sensor.paris_temperature, HA said that this entity ID already exists. Not good.

I had a look at .storage/core.entity_registry and I see that, indeed, sensor.paris_temperature is still there. More alarming is the fact that the file has about 1250 lines, out of these about 1160 are “deleted entries”. 1250 - 1160 = 90, HA says that I have 1158 entities. This does not add up.

Question 1: what are “entities” and “deleted entities” in .storage/core.entity_registry?

Question 2: why are entities from an old integration still there?

Question 3: is there a way to “vacuum” this file to get rid of such hanging entities?

1,2,3 is easy to be answered, the core* files are sort of the counterpart to your brain. You do remember you had netatmo installed, so do the core* files in their deleted_xxxxx sections, that simple.

The normal process would be

  1. uninstall netatmo (now the integration is gone)
  2. restart home assisstant (then entities are gone)
  3. reinstall the integration

If you skip the 2nd step the entities are still there resulting that 3rd step needs to create the entities with a “_2” at their end because the required name already in use.

Normally you should be albe to delete the one without “_2” now since being unavailable and then remove the “_2” from the newly created entity.

  1. uninstall netatmo (now the integration is gone)
  2. restart home assisstant (then entities are gone)
  3. reinstall the integration

This is incorrect. I restarted HA a few times in between the installations, but I did the exercise once again a moment ago. After uninstalling Netatmo and restarting HA I now have two entries (one plain and one with _2) in .storage/core.entity_registry

that simple.

No, it is not that simple. paris_temperature is still in “entities” (which means it is taken) and there are two paris_temperature_2 in “deleted entities”.

you’re sure you ‘restarted’ home assistant, not just

devtools>restart>quick reload
but
devtools>restart>restart home assistant
if not
devtools>restart>advanced options>reboot system ?

I do ask because it looks as if you once did it the wrong way and since so the entity is still taken.

If that all won’t help, there’s also the possibily it wasn’t created by netatmo.

devtools> then filter entities until you found the actual one
then a click upon the small i in the circle
a window should open
press the 3 dots and then press ‘related’

you should get some information about where it comes from or what it’s used by

I restart HA’s container

This is true, but since it is not listed as an entity by HA, there is a problem somewhere anyway.

I will write a utility to map devices to entities based off the .storage data and I will see more in depth how big the mess is.

It’s not there, just in .storage