Where are device names kept now

I understand that known_devices.yaml is no more but the data has to be somewhere … so where is it ?
The context: ESPHome - when you upload the config file for the particular device you name things like switches. If you re-name the switch because you changed your mind, sometimes Home Assistant or ESPHome looses it’s marbles and somehow marks the name as bad or something. Note I did not say ‘unavailable’.
I spent the last 2 hours trying to name a switch a certain name and I suspect that somewhere along the line I had used the name and then deleted it. It is not in known_devices.yaml, it is not in entities (even when you show all entities including the unavailable ones). If I change the config file for that particular device I can call the switch let’s say ‘switch b’ and it shows up as an entity in HA (ie newly created) but if I name that switch ‘switch a’, it does not show up as an entity … presumably because at one point that name was used and then deleted but HA or ESPHome still has it in a file someplace and says ‘hey, that entity was created so I don’t need to create a new entity with that name’.
Very frustrating.

All somewhere under .storage directory.

Looked there but couldn’t find anything…

did you grep for switch a?

No, don’t know how to search across all the different files in the directory

grep switch\ a *

I did a grep wemos* (wemos instead of ‘switch a’) with no result (ie it continues searching and I have to abort)

You missed a space
grep wemos *

not

grep wemos*

forgot a space between wemos and * … if I search for the corrected search, I get a hit in the Lovelace screen but nothing in terms of entity names

Well I am at a loss to know where it is stored then.

The esphome addon stores stuff in a directory called esphome, which is in the same directory configuration.yaml is in.

Ok, used another search term and came up with core.entity_registry … I will check that out.
I also checked the ESPHome directory but haven’t done a grep in that yet but will do that next.
Thanks, I got places to search now.

Yup, it’s in the core.entity_registry … but I am hesitant to mess with it manually. I can see me messing things up big time! I think I rather use a name that departs slightly from my naming convention.
Thanks! I appreciate the help !

Back up that directory before you touch it! (If you decide to touch it).

For sure … backing up the directory and taking a snapshot would be required but I think I will leave it be - the entries look pretty intimidating.

… maybe on a weekend when I have nothing better to do :slight_smile:

Yeah you miss a comma or a bracket and the whole system is f***ed.

And people think yaml is hard…

I’m late to this party, but grep -r wemos *. It seems you were in the top-level directory and only searched through the files there. That option makes it traverse all the child directories.

Thanks for chiming in. In this case I was in the .storage directory which is mostly flat with no sub-directories (well I have the hacs subdirectory).
I will try to remember the -r switch in the future.

You can remove it from the UI… Go to the esphome device in question and delete it. If it’s an entity, sort by entities and delete it.

Configuration -> Entities… Then find the entity and delete.

Whenever I have a naming conflict, that’s what I do and it works like a charm.

EDIT: This only works when the entity can be deleted (I.e. it’s orphaned). Which it should be because ESPHome screwed up.

EDIT2: You can even sort by status and all the ones with the funky symbol are orphaned and can be deleted.
image

Some entity can be deleted that way and I have done that before. Unfortunately there is a disagreement between me and HA about what entities are orphaned and HA is holding the entities hostage :slight_smile:
I have not figured out yet how HA decides when an entity is orphaned or not but in this case Configuration -> Entities-> Show all does not show the entity in question.
I will double check but I did try that.

Just for the record - I screwed up to start with. ESPHome has always created the entity. When I delete the name in the ESPHome device, that is when the device should in theory be orphaned but it doesn’t seem to be tagged as such in the entities file in .storage

Edit:
Just found an entity that no longer exists (in configuration entities show al and tried to delete it but it is not considered orphaned. I am currently rebooting the host computer to see if that helps to get the entity orphaned.

Ahh, that worked and I can clean up a bunch of mis-labeled entities that way … but I am not sure about the entity in question yet … will dig further and report back

Partial success - if an entity is marked as ‘unavailable’ and I specifically go into that entity and enable it and then reboot the host computer. it then shows up as orphaned and can be deleted.
Sometimes the entity does not show up as orphaned but the ‘delete’ button in the entity itself becomes available and can be deleted that way.
Apparently I can also just restart the HA server - a bit quicker than rebooting the host computer.

To sum it up, given the right combination of secret handshakes, the entity can be removed! I was able to name my switch the way I wanted it (yeah). Things are not entirely consistent or clear or user friendly but can be made to work!
Talking about ‘consistent’ - the check box at the far left of the device list is also inconsistent and is sometimes marked on the screen when it has not been marked by the user. Not a biggie but more of an annoyance.

Thank you very much for helping me to clean up things in my installation!