#All ESPHome selects have changed their entity_id on update

1 messages Β· Page 1 of 1 (latest)

solid pulsar
#

entity ids that were previously in the entity registry should never change as the entity_id is always fetched by the unique id

#

The only way I could see that happening is that the unique id changed

tawny fossil
#

Ah I seeeee

#

so all entity IDs have been changed. well, at least some

solid pulsar
#

thats very concerning as the integration can only suggest an entity_id, it should never be able to change an existing one

#

the entity_platform is responsible for restoring the previous entity_id based on looking up the unique id

tawny fossil
#

yea, these have been changed as well

tawny fossil
#

Ip addresses are only gathered, these are not shown anywahere, so I did not noticed that entity ID change

solid pulsar
#

I've dug through the entity platform code, and can't find any potential restore issues there. I wouldn't expect any since we would have seen this before.

tawny fossil
solid pulsar
#

let me dig through the registry code.. may be there is a long standing bug there

tawny fossil
#

probably it added only changed entities which were not used anywhere.

#

I have two select entities. one changed ID in the dashboard, the other one not and I needed to change it manually to the one with prepended device name

fierce solstice
tawny fossil
#

it is not showing it, just modified

#

but the entity id has been changed after upgrade. so there is no history

tawny fossil
#

other entities without changed entity id have a history

solid pulsar
fierce solstice
solid pulsar
#

we persist the actual entity id

fierce solstice
#

Oh wait. Now that I'm writing it, it probably doesn't make sense

#

Given the indices

solid pulsar
#

grep gate.mcu_gate_gate /config/.storage/core.entity_registry. (edit: fix to be .storage)

#

what does that show?

tawny fossil
solid pulsar
#

can you do mcu_gate instead of mcu-gate ?

tawny fossil
#

copy/paste doesnt work... grr

#
➜  ~ grep select.mcu_gate /config/.storage/core.entity_registry 
      {"aliases":[],"area_id":null,"categories":{},"capabilities":{"options":["Open","Closed","Opening","Closing"]},"config_entry_id":"b641feff25b89504b2d3b9eea65a00f8","config_subentry_id":null,"created_at":"1970-01-01T00:00:00+00:00","device_class":null,"device_id":"27377805d4a10b69213d1d3556453bd7","disabled_by":null,"entity_category":null,"entity_id":"select.mcu_gate_gate","hidden_by":null,"icon":null,"id":"72aa006c0b1754ba4fb4f2f426dca648","has_entity_name":true,"labels":[],"modified_at":"2025-04-30T21:41:15.258764+00:00","name":null,"options":{"cloud.google_assistant":{"should_expose":false},"conversation":{"should_expose":false}},"original_device_class":null,"original_icon":null,"original_name":"Gate","platform":"esphome","supported_features":0,"translation_key":null,"unique_id":"94:B9:7E:8D:97:E0-select-gate","previous_unique_id":null,"unit_of_measurement":null},
#

downloading backup (16 GB) will compare it before upgrade

#

downloading from HA is crashing. hm

solid pulsar
#

{"aliases":[],"area_id":null,"categories":{},"capabilities":{"options":["Open","Closed","Opening","Closing"]},"config_entry_id":"b641feff25b89504b2d3b9eea65a00f8","config_subentry_id":null,"created_at":"1970-01-01T00:00:00+00:00","device_class":null,"device_id":"27377805d4a10b69213d1d3556453bd7","disabled_by":null,"entity_category":null,"entity_id":"select.mcu_gate_gate","hidden_by":null,"icon":null,"id":"72aa006c0b1754ba4fb4f2f426dca648","has_entity_name":true,"labels":[],"modified_at":"2025-04-30T21:41:15.258764+00:00","name":null,"options":{"cloud.google_assistant":{"should_expose":false},"conversation":{"should_expose":false}},"original_device_class":null,"original_icon":null,"original_name":"Gate","platform":"esphome","supported_features":0,"translation_key":null,"unique_id":"94:B9:7E:8D:97:E0-select-gate","previous_unique_id":null,"unit_of_measurement":null},

#

"94:B9:7E:8D:97:E0-select-gate"

#

thats the unique id

#

so whatever was in the registry before the update for that unique id should have been preserved

#

# <mac>-<entity type>-<object_id> return f"{formatted_mac}-{_TYPE_TO_NAME[type(entity_info)]}-{entity_info.object_id}"

#

thats what ESPHome uses to define the unique id

tawny fossil
#

and what about entity id? so the new behavior is if there is no friendly_name just to use device name instead?

solid pulsar
#

"created_at":"1970-01-01T00:00:00+00:00" means the entity registry entry was created before v1.15 of the entity registry where created_at was added so its set to 0 which implies that the registry entry has been there for a while, so the entity_id should not have changed.

solid pulsar
tawny fossil
#

but this is new. because it was using just entity name: defined in esphome.

solid pulsar
tawny fossil
#

the whole prepending device name and Camel-Case is driving me insane πŸ˜„

#

people who have ugly device names (all my esphome devices have that mcu- prefix) is this not good way. sure, I could add friendly_name, but this would need to basically change all names in config and then rename everything in HA

solid pulsar
#

Yeah, I hear you. Unfortunately, that ship kind of sailed in 2023 β€” Home Assistant fully switched over to the new entity naming format.
https://developers.home-assistant.io/blog/2023/06/28/entity-name-changes

Since then, all new integrations have to use has_entity_name=True:
https://developers.home-assistant.io/docs/core/entity#has_entity_name-true-mandatory-for-new-integrations

And it's part of the integration quality checklist now too:
https://developers.home-assistant.io/docs/core/integration-quality-scale/checklist

Definitely a change, but it’s the direction everything’s moving in now.

tawny fossil
#

for example. In the basement I have multiple devices driving lights and sockets. All have prefixed name Basement. So I really cannot use friendly_name

#

then when one device is for multiple purposes - so a "Sewage Treatment Blower" has no Basement on front as it doesn't make sense

solid pulsar
#

If you have a suggestion on how to improve it that conforms with the has_entity_name requirement, I'm happy to try to implement it.

tawny fossil
#

basically - internally just use any uniq_entity_id you want as it is not visible. but for the name and id just preserve that one that is set.
if friendly_name: is not set, just use entity name:
if friendly_name: is set, then use it as a prefix πŸ™‚
so basically like it was before πŸ˜„

#

the exemption for esphome was there because it is not used just for simple sensors or lights

solid pulsar
#

So you're basically asking to restore the exemption, which makes sense. The tricky part is we can’t do that unless we remove the quality scale from ESPHome.

tawny fossil
#

and I am not using any voice features at all, because it cannot work with properly configured entity names. it is always pushing these crazy names there

solid pulsar
#

So effectively, what you're asking for would mean changing the architecture in Home Assistant to undo the 2023 naming changes

tawny fossil
#

the nice example was the kincony with 256 channels - you cannot just prepend the device name if it is driving the whole home

solid pulsar
#

I don’t have the ability to unilaterally change Home Assistant’s architecture, but I'm happy to work within the existing structure to improve what I can.

tawny fossil
#

did not check it yet, but this idea came after the last breaking change that was then rolled back

#
  • it is needed when esphome is just a hub - for devices connected via ble, rs485, can,...
solid pulsar
#

that HA PR linked to that looks very incomplete. It likely barely scratchs the surface on what would be needed

#

without getting too much off topic

#

Were you able to get the original entity registry entry from above?

tawny fossil
#

still downloading

#

ha ha..maybe I could look into influxdb - I guess everything is broken as renaming entity_id is not a good idea

tawny fossil
#

old one (2024.4)

      {"aliases":[],"area_id":null,"categories":{},"capabilities":{"options":["Open","Closed","Opening","Closing"]},"config_entry_id":"b641feff25b89504b2d3b9eea65a00f8","config_subentry_id":null,"created_at":"1970-01-01T00:00:00+00:00","device_class":null,"device_id":"27377805d4a10b69213d1d3556453bd7","disabled_by":null,"entity_category":null,"entity_id":"select.gate","hidden_by":null,"icon":null,"id":"72aa006c0b1754ba4fb4f2f426dca648","has_entity_name":false,"labels":[],"modified_at":"1970-01-01T00:00:00+00:00","name":null,"options":{"cloud.google_assistant":{"should_expose":false},"conversation":{"should_expose":false}},"original_device_class":null,"original_icon":null,"original_name":"Gate","platform":"esphome","supported_features":0,"translation_key":null,"unique_id":"94:B9:7E:8D:97:E0-select-gate","previous_unique_id":null,"unit_of_measurement":null},
#

and the new one

      {"aliases":[],"area_id":null,"categories":{},"capabilities":{"options":["Open","Closed","Opening","Closing"]},"config_entry_id":"b641feff25b89504b2d3b9eea65a00f8","config_subentry_id":null,"created_at":"1970-01-01T00:00:00+00:00","device_class":null,"device_id":"27377805d4a10b69213d1d3556453bd7","disabled_by":null,"entity_category":null,"entity_id":"select.mcu_gate_gate","hidden_by":null,"icon":null,"id":"72aa006c0b1754ba4fb4f2f426dca648","has_entity_name":true,"labels":[],"modified_at":"2025-04-30T21:41:15.258764+00:00","name":null,"options":{"cloud.google_assistant":{"should_expose":false},"conversation":{"should_expose":false}},"original_device_class":null,"original_icon":null,"original_name":"Gate","platform":"esphome","supported_features":0,"translation_key":null,"unique_id":"94:B9:7E:8D:97:E0-select-gate","previous_unique_id":null,"unit_of_measurement":null},
#

its late 2:35... if something, I will provide it on the morning πŸ˜„ guess only way for now is to restore from backup and hope that at least entity ids will be not changed later

#

the nice thing on this was that I could move some functionality from one device to another and when entity id was the same the history was preserved. now it will be not possible anymore. many thanks for now πŸ™‚

solid pulsar
#

I'll keep digging and try to replicate the entity_id changing. I haven't had any luck with downgrading/upgrading so far. That points to a larger bug in the entity registry

solid pulsar
#

I've tried downgrade, upgrade, etc. I can't reproduce this. I'm not doubting there is a bug there but I have had no luck getting the entity ids to change

solid pulsar
#

Still no luck. Going to need some way to reproduce this. I’ll try again tomorrow after some sleep

tawny fossil
#

I have restored it from backup, maybe I can upgrade again :))

solid pulsar
#

that would be great as I'm still beating my head against the wall trying to reproduce it

#

0315 here so I have to get some zzzs

#

I'll try again in the morning

#

If you manage to reproduce it please send the yaml file. Ill flash it on something similar and than set it up and upgrade

fierce solstice
#

That one PR wasn't the only thing that changed with naming

solid pulsar
#

thats just the suggested one

fierce solstice
#

Oh is it suggested entity id?

solid pulsar
#

the entity platform is responsible for the final value

fierce solstice
#

I thought you would set the entity id

solid pulsar
#

when a unique id is set

#

yeah its not confusing at all 😜

fierce solstice
#

interesting, I always thought it overwrote it

mental mortar
#

has_entity_name swapped from true if using friendly name, to true for all entities in this release?
Would that have caused it?

solid pulsar
#

That should have zero effect on and already registered entity id with a unique id (unless we have a bug in core somewhere)

#

I’ll write a whole lot of tests in the morning. Maybe something will shake out

#

I still cannot reproduce it manually no matter how many times I upgrade downgrade upgrade etc

#

Anyways 0415 here so I’m not going to make any more progress tonight

#

Gnight.

tawny fossil
#

so upgraded from 2025.4.4 to 2025.5.0b1 and again many entity_id's have been changed

#
  • if entity_id is used in the dashboard, then it's name is still the same
  • if it is select.*, then it is changed even it is being used in the dashboard
  • any other unused entities in the dashboard gets changed - well, not always true. only in some cases sad
urban prawn
#

If that helps, my Athom wall switches have selects for the config and none of the entities have changes when upgrading from 2025.4.x to 2025.5.0b0 and today b1.

tawny fossil
#

yea... maybe it is related only some old devices which are missing something, so this is the reason why ha is handling newer correctly

#

I have created select on a newest node where are all entities fine and it added device_name as prefix

#

ok.. so i removed it, it was automaticlaly discovered and all entities have that device_name as prefix CryingBoy

tawny fossil
#

probably I cannot fight since the prefixed device_name / friendly_name is now mandatory, so I have two options. Stick with 2025.4 for my entire life, OR add friendly_name to ~50 my devices and change their names too + modify entity names and since it will add mess, then fix names too

#

and I don't agree that it is not a breaking change - it is changing behaviour how new (in some cases it might impact old ones) entities are named, so it is a breaking change.

urban prawn
#

Best is to start over/fix the names.

tawny fossil
#

so bye bye my history and data in influxdb πŸ˜„

nocturne tundra
#

There is 1 unavailable select. Tbh, I am not sure at all this wasn’t already like that, as I don’t use Wakefield

tawny fossil
#

not great decision with this prefixing. first should be the sub device support added and then this might be ok for the hub itself.

#

nope. friendly_name is not good. - I need that "mcu-" as device name, but I don't want that in entity_id πŸ˜„ Ah, even it is showing friendly name on the background it is using device name, ha ha. this is so weird.

#

This is too big change. Need to rework common part, every config, then every device will have an ugly name - I want that hostname, otherwise it will be not matching with stickers on devices. And even it will not touch old devices every new device have to follow that standard and it will automatically prefix device_name / friendly_name, which is totally breaking everything,
Hope this change will be again reverted as it is not good

urban prawn
#

then re-generate the entities

#

and study how to change entity names in the database (what commands to run)

#

and then run it on the main database

#

and you'll have history

#

not great, not terrible, tho

tawny fossil
#

I don;'t want to change their names. so I will not upgrade, because this change is messing with everything

urban prawn
#

if I can give you some motivation, I will also rename entity names since I fucked up from the start when learning HA πŸ˜„

#

my entity names are sensor.device_name_brand_sensor_type

tawny fossil
#

if you like that, your choice, but HA is not apple....it should not force me to use his naming convention because somebody decided he likes it more πŸ˜„

#

in the old times I could easily move entity from one device to other and history was preserved. now even it has a device id and uniq entity id in db it needs such crazy entity id. it is so weird

solid pulsar
#

maybe something to do with the storage....

#

still writing tests

#

haven't found an issue yet

solid pulsar
#

Maybe someone can see something I'm missing

tawny fossil
#

back to 2025.4.4. started adding friendly_name to all dev devices, but device name is prefixed instead CryingBoy - restarted everything and still it is doing it wrong (in github there are many such issues and always ended autoclosed). would expect that this issue is fixed first and then you can force friendly_name...

solid pulsar
#

Is there a specific issue that didn't get solved that you can point to?

tawny fossil
#

but this is 2025.4.4. will try beta in a minute once docker gets updated

solid pulsar
#

here is how its documented to work

tawny fossil
#

ah ok, so friendly name is just for the name, entity_id will always have its hostname. meh

solid pulsar
#

yup

soft venture
tawny fossil
solid pulsar
#

I've flashed 6 different devices and upgraded and downgraded countless times

#

I can't get it to break

#

at this point I feel like I've hit a wall

tawny fossil
#

even the migration is not working right at least it will force people to migrate to that new naming. nabucasa is like apple πŸ™‚ they know what is the best for users and they will not give us any other option πŸ˜›

soft venture
#

I have set name = friendly name so no issue here 😬

tawny fossil
#

I really don;t understand why theyu are doing it - HA knows to which device it belongs and with the new picker it is showing all needed info about entity, so this forcing is totally unnecessary

solid pulsar
#

If you post the yaml from one of the affected devices, I'll try flashing it, setting it up on 2025.4.x, and than upgrading to 2025.5.x

tawny fossil
solid pulsar
#

got it flashed

#

its not showing as a discovery

#

thats odd

#

nevermind it got the IP of an existing device

#

{"aliases":[],"area_id":null,"categories":{},"capabilities":{"options":["Open","Closed","Opening","Closing"]},"config_entry_id":"01JT9DQKNXJKDKJCED0283RQBR","config_subentry_id":null,"created_at":"2025-05-02T21:16:41.707741+00:00","device_class":null,"device_id":"0b9d8aad7c89f9fd32a8e34d8addce97","disabled_by":null,"entity_category":null,"entity_id":"select.gate","hidden_by":null,"icon":null,"id":"c01eb6b218fa5c73a5d738ad9ec9d305","has_entity_name":false,"labels":[],"modified_at":"2025-05-02T21:16:41.708468+00:00","name":null,"options":{"cloud.alexa":{"should_expose":false},"cloud.google_assistant":{"should_expose":false},"conversation":{"should_expose":false}},"original_device_class":null,"original_icon":null,"original_name":"Gate","platform":"esphome","supported_features":0,"translation_key":null,"unique_id":"1C:69:20:EA:57:50-select-gate","previous_unique_id":null,"unit_of_measurement":null},

#

going to update now

#

stayed the same for me

#

checking the registry

#

{"aliases":[],"area_id":null,"categories":{},"capabilities":{"options":["Open","Closed","Opening","Closing"]},"config_entry_id":"01JT9DQKNXJKDKJCED0283RQBR","config_subentry_id":null,"created_at":"2025-05-02T21:16:41.707741+00:00","device_class":null,"device_id":"0b9d8aad7c89f9fd32a8e34d8addce97","disabled_by":null,"entity_category":null,"entity_id":"select.gate","hidden_by":null,"icon":null,"id":"c01eb6b218fa5c73a5d738ad9ec9d305","has_entity_name":false,"labels":[],"modified_at":"2025-05-02T21:16:41.708468+00:00","name":null,"options":{"cloud.alexa":{"should_expose":false},"cloud.google_assistant":{"should_expose":false},"conversation":{"should_expose":false}},"original_device_class":null,"original_icon":null,"original_name":"Gate","platform":"esphome","supported_features":0,"translation_key":null,"unique_id":"1C:69:20:EA:57:50-select-gate","previous_unique_id":null,"unit_of_measurement":null},

#

I did use an esp32dev board

#

but I don't think that would make any different. HA doesn't treat specific boards differently

tawny fossil
#

really weird πŸ˜„

#

but to be honest, I really hate these friendly names. For example I have a device in a Well and in a Shed, both are driving irrigantion - circuit A and B. and now it is called Well Irrigation A... and Shed Irrigation B πŸ˜„

#

the same for NSPanels - driving lights, but it must be called Bedroom NSPanel Light and not just Bedroom Light as before

shell lichen
#

Do you hate it? I am just shocked to hear that.

tawny fossil
#

sure, I can override everything, it is just silly requirement

haughty ravine
#

Every integration follows this paradigm. Complaining more and more about it isn't going to change it. It was decided long ago and every integration that creates devices and entities adopts this default naming convention.

tawny fossil
#

but it doesn't mean it is right πŸ˜„

tawny fossil
#

just accidentally upgraded to 2025.5.0b2 and it is not changing my entity_id's, so I guess it has been fixed (I slowly, as it is a loot of work, started adding friendly_name and reimporting them to make you happy πŸ˜„ :D)

urban prawn
#

you went from 2025.4 to 2025.5.0b2 directly? Or you had some renaming done before?

urban prawn
#

The 5.0b3 has this in docs:

Add tests to ensure ESPHome entity_ids are preserved on upgrade (@solid pulsar - #144116)

tawny fossil
#

yes, this issue was about that messing with entity_id's which was true with b0, but it has been fixed, so all good now πŸ™‚ - then no, that select waas changed again..

#

but, unfortunately, we have to rename them anyway, because in case I would remove a device and add it back, then all entities will be created based on the new naming convention so it is better to do it now than later

urban prawn
#

@tawny fossil a question outside your - what hardware you have for CAN and how do you interface with it from HA?