Is it possible to automatically update sensor names but still use custom UI?

Hello everyone,
so, I have created a custom UI (in addition to keeping the system’s Overview, which automatically updates) and after I modified some device names and had the system also rename the connected entities, those binary sensors are no longer available in my custom UI. This kind of makes sense, because I changed their names.
But in the Overview UI, this was automatically corrected.

So the question would be: Is it possible to link to the unique identifier rather than the given name? Or somehow else make sure that when I change the name of a device and its entities, this change is automatically transferred to my UIs?
After all, it is still exactly the same device and entity, I only changed its common name.

Thank you for your support and feedback!
Alex

The entity id is the unique bit to which you link. You can change the friendly name of a device all you like and it will get updated everywhere it’s displayed. But if you change the entity id you change the unique bit and you have to change it everywhere you used it yourself.

Ah, that does not sound smart. After all the entity ID is not a background number/name like a MAC, it is a name that helps you identify the sensor etc. in the frontend. So it will generally be linked to the name of the device.
If I have 20 sensors which are all named sensor.DeviceName.sensortype and I change the device name, then to me it would be obvious to also change all entity names. Otherwise it becomes impossible to find/track/assign.

If e.g. initially the device would have been named shelly_livingroom, then the entities would be
sensor.shelly_livingroom.voltage
sensor.shelly_livingroom.consumption

But when I add a second Shelly in that room, I would like to name them e.g. Shelly_Lights_LivingRoom and Sensor_Sockets_LivingRoom. And if the sensor entity is not changed, I will not know in a year that the above sensors belong to Lights and not the later installed sockets.

Why does the UI not use e.g. the MAC or some other unique, non-configurable name in the background?

Why would it? Just be more specific when you add a device. Or just only edit the Friendly name to whatever you want and just tread the entity_id as something unchangeable. :wink:

Because the entity_id is editable. Okay, maybe this is a matter of opinion, but if all integrations bound the devices and entities to unique, unchangeable syntax (e.g. MAC address), then you could change any IP and change any name at will without anything being negatively affected.
If anything, in this case the UI/Lovelace, assigns the bindings to an editable name (and the system even by default wants to change the entity name when you change the device name), then this will always damage the user’s UI.

It’s open source, we don’t like uneditable :wink: And even a MAC address can be changed (/ spoofed) :angel: One thing changing the entity id is good for is when you swap a sensor but don’t want to change a thing. And HA does make it pretty clear what the consequences are when you do change an entity id. It just gives you the option so I would not say it’s the default.

Well, I meant uneditable from UI, not from files of course :wink:

I am still trying to get a hang of things and am learning something new everyday.
I just think this is a source of long terms problems because new installs will suffer from this problem. So one day it will force people to redo their setup or put in a lot of work.

I guess most experienced users redo their systems in a heartbeat. But for me this is a tricky problem.
So I now have to think of a log term naming scheme.

Hehe :smiley: Unfortunately that’s not possible because not all entities are ported back to the YAML. Yeah, still think that’s a shame as well. But I would say the large warning you get now is sufficient as well :stuck_out_tongue: And it looks like it works because the number of problems because of renamed entities is very few.

I’ve used HA for over three years (maybe four) and have never had to “redo” my system because of anything to do with entity_ids.

I’ve read this whole thread and I’m still not sure what you are trying/want to change.

If an integration creates a “device” (not all do) then the system gives you the ability to change all of the child entities to the name of the parent device if you want. If you don’t then you don’t have to.

If the system adds another device or entity that would create the same entity_ids as an existing one then it will append the entity_id with a sequential number (“_2”, “_3”, etc). Then it’s up to you to make the entity_id more descriptive if you want.

If you want to manually change the friendly name for the entity to improve the display in the front end then you can do that entirely without changing the device name or the entity_id of the entity.

You can manually change any entity_id to pretty much anything you want to make it more descriptive as long as you follow the naming conventions in HA (no uppercase, no dashes, etc).

If that doesn’t describe what you are trying to accomplish please try to explain it again.

Yeah, I guess I will have to rename all my devices to something new and then change the friendly names.
Especially since sensor names are being cut off in (at least some of the) GUI components. So I need to think of a naming scheme for my entities that allows easy identification from the entity_id alone.