ESPHome devices all renamed with _2 added

All my ESPHome sensors got replaced with the same names with _2 appended this morning. I think it happened with the latest HA Core update, but not sure.

I was going to try a restore to a backup, but would rather not if there is a known way to fix this.

Go to congifuration → devices and Services, there find integration “ESPHome” - there you’ll find all your ESPHome devices. Delete all integrations/ESP devices from there one by one, then re-add them (add integration -->esphome -->enter IP and password). That way you’ll get your original names back.

2 Likes

Yes, this is frustrating. There is a delete button, but if you see something like this:

You can only remove 0 of the selected 5 entities. Entities can only be removed when the integration is no longer providing the entities. Sometimes you have to restart Home Assistant before you can remove the entities of a removed integration. Are you sure you want to remove the removable entities?
… then you have to remove the integration before you can delete the duplicate devices.

Restart HA then go back to integrations, and during the restart HA will have discovered your devices again.

I AM NOT AN EXPERT. This is from my notes when I recently tried to delete some duplicate devices.

Same thing happened to me when I updated ESPHome last time (or maybe the time before last, I forget.)

I, too, had to delete the integration and re-add it. I only have one ESP device, but I can see this would get old quickly if you had a lot of them.

The good news is that all my Lovelace cards, templates and automations worked fine once I re-added the device. So at least not much lost data or effort.

1 Like

You can remove some of unavailable entities in developer tools, but in general, a much better idea is to remove and re-add whole integration. By removing ESPHome integration nothing in lovelace cards will break. Once you re-add it all will function again, because old names will again become “available”.

2 Likes

This happened AGAIN. Do I need to go through this hassle every few months with HA/ESPHome updates?

Yeah just happened to me with 2023.12.3. I have many entries and there’s no known reason here. Anyone raise a ticket yet?

1 Like

Ticket is here:
home-assistant/core#106159

This won’t be fixed.
It is an intentional breaking change of ESPhome 2023.12.x.

The good news is that it is a really simple fix.
DO NOT rename all of your entities!
Instead:

  • Compile your ESPHome node with 2023.12.1 or higher, so it shows double entities. Do NOT use 2023.12.0 as there is another code change from .0 to .1 that will break your entities again.
  • Remove the ESPHome node (Settings → Devices and services → ESPHome → 3-dot-menu of node → Delete).
  • Wait for HA autodiscovery to find the node again. It will be displayed in Devices and services. Or restart HA to force immediate discovery.
  • Add the node again (click “Configure” under the discovered node).

The history of the entities will NOT GET LOST by this process.
Make sure you have your encryption key at hand, in case you will be asked for it when re-adding the node. Most often you won’t.

Hot tip: You may want to test the whole process with only one less important ESPhome node before you go all in with all your nodes.

2 Likes

If an update requires a “fix”, then the update is broken. WHY does the “_2” suffix even exist? In my dev tools/states I have more “unavailable” than useable entities because of this “feature”. Why not just simply overwrite the existing entity when a device is updated?

1 Like

I guess that because it’s really impossible to know whether certain entity is only updated or created new with (by mistake?) same name as existing one.

But, i agree that this with friendly name is a biiiig mess… i don’t use it, i simply don’t write “friendly_name” in my yaml’s under “esphome”. I rather use substitutions and define “${friendly_name}” and “${device_name}”. Then i add (or not…) this before each id/name. Ok, its somewhat more work, and generally i always do have this name before each entity, to distinct them and to always quickly know which esp belongs to. But, there are occasions where i don’t use this prefix…
But, i think that main reason i quickly stop using “friendly_name” (back then when it was introduced) is that friendly name WAS added before name, but WASN’T added before id. I like my entities named same under “id” and “name”. Perhaps now it’s different, but i don’t know and i don’t explore it anymore…

No. It is a “breaking change” and it was labelled as such.
I agree that the extent of breaking could have been communicated more clearly.

It’s not too late to update the breaking change notes. I guarantee more people are stumped here. @jesserockz ?

1 Like

Just how far should ESPHome go to protect users from themselves? Why should we all suffer from the “_2” nonsense because of one user not paying attention to device naming.

3 Likes

Hm…if it was it was written pretty hidden… i always read all changes before i update, but i didn’t notice that “breaking change”… breaking changes should be labelled very clearly…
Simlar as last card-mod: it was breaking change the other day, but not very clearly labelled…so many people had problems (including me).

I would expect breaking changes in the release notes under the headline breaking changes

Ensure names containing characters other than a-z A-Z 0-9 or _ are unique esphome#5810 by @bdraco (breaking-change)

But not sure if their actually was a bug and even names with the “allowed” characters started to act up

3 Likes

I too was having the same issue with Esphome renaming my devices adding the “_2” behind the name. I don’t know if this issue has been fixed or not. I’m assuming not because I’m using the latest verison. However, I did run across something interesting and by accident, that has been working for me and it hasn’t renamed any of my devices when ever they needed updated. From the Esphome Dashboard don’t use the “UPDATE ALL” or the Devices “Update” option. Instead go the edit, on the device, and choose install and your install choose method. It will compile the firmware and install as normal. When its finshed installing the Esphome Dashboard won’t show it needs updated anymore and the device retains it original name in Home Assistant.
I have 80+ Esphome devices and out of the last 10 I have used this method not a one of them has been renamed in Home Assistant with the “_2”.
The bad part for me is I went through 30+or- device updates with this renaming issue before I accidently discoveried this method I mentioned above.

Hope this is helpful to you all.

1 Like