home-assistant / frontend

:lollipop: Frontend for Home Assistant
https://demo.home-assistant.io
Other
3.83k stars 2.62k forks source link

Entity IDs are not renamed #19635

Open AngellusMortis opened 5 months ago

AngellusMortis commented 5 months ago

Checklist

Describe the issue you are experiencing

If an entity's entity ID does not match the entity/device name, choosing "Rename Entity IDs" will not work on the entity ID.

Describe the behavior you expected

Entity IDs should be renamed according to new device name

Steps to reproduce the issue

  1. Open device
  2. Click Edit in Top Right
  3. Update Device Name
  4. Click "No" on the confirmation prompt to rename Entity IDs
  5. Update the Device Name again
  6. Click "Rename" on the confirmation prompt to rename Entity IDs

https://github.com/home-assistant/frontend/assets/490848/e1d89dd7-1bb9-4c7c-83b8-a3900e84e710

This is also re-producible if the device/entity names are updated from upstream. In my case, I renamed the devices in UniFi Protect and reloaded the integration so the devices/entities would get their new proper names. Now I cannot rename the device manually to bulk update all of the entity IDs.

Bulk renaming the entity IDs is really useful for upgrading/replacing devices which is what I am doing here. I replaced 4 outside cameras with newer models. Renamed the old ones and then disabled them. Then renamed the new ones to match what the old ones were.

What version of Home Assistant Core has the issue?

core-2024.1.6

What was the last working version of Home Assistant Core?

2023.12 ish? maybe?

In which browser are you experiencing the issue with?

Edge (Chromium)

Which operating system are you using to run this browser?

Windows 11

State of relevant entities

Enabled and working? Basically trying to upgrade/replace a device.

Renamed old device, verified entity IDs on it were renamed. Then disabled it. Renamed replacement device, all of the entity IDs are still the old default name (ai_pro_*).

Problem-relevant frontend configuration

N/A.

Javascript errors shown in your browser console/inspector

None.

Additional information

The device does have a lot of entities that may be causing it (40+).

Alex-joomla commented 4 months ago

I even don't get the dialogue box where HomeAssistant asks if it should rename the entitys accordingly

karwosts commented 4 months ago

I even don't get the dialogue box where HomeAssistant asks if it should rename the entitys accordingly

Note the dialog popup is only given to users with "Advanced Mode" enabled.

karwosts commented 4 months ago

When renaming entity ids, ids are only modified if the entity id contains exactly the slug of the old device name, and only that subset of the entity id is modified to the new name.

So if you're renaming "Foo Device" to "Bar Device", sensor.xxxx_foo_device_yyyy will be renamed sensor.xxxx_bar_device_yyyy, but an entity that does not contain the string foo_device is not modified.

If you want to bulk rename entities that don't match the current device name, you may be able to take advantage of this by renaming the device multiple times, first rename it such that it matches the part of the id that you want renamed, and then try renaming it a second time.

ildar170975 commented 4 months ago

only given to users with "Advanced Mode" enabled

Off-topic, but so far see no reason to have this "advanced mode" disabled.

shred86 commented 3 months ago

When renaming entity ids, ids are only modified if the entity id contains exactly the slug of the old device name, and only that subset of the entity id is modified to the new name.

So if you're renaming "Foo Device" to "Bar Device", sensor.xxxx_foo_device_yyyy will be renamed sensor.xxxx_bar_device_yyyy, but an entity that does not contain the string foo_device is not modified.

If you want to bulk rename entities that don't match the current device name, you may be able to take advantage of this by renaming the device multiple times, first rename it such that it matches the part of the id that you want renamed, and then try renaming it a second time.

Thank you @karwosts for sharing this. I could not figure out why sometimes the device_id would not update and this is the reason. I do think this is a bug because you still get the dialog asking you if you want to rename your device_id, but it's not actually doing anything which makes it very confusing.

Update: Okay, I don't know what's going on but it seems to be working now. I did allow it to have cloud access yesterday to double check some settings but that's about the only change I've mad recently. I'll keep an eye on it to see if it continues to work.