I find it bothersome when I have to rename devices with many entities such as the one in the picture. It would be nice to have a “bulk renaming feature” that could rename all the related entities at once. I suggest the largest common naming-overlap between all entities is considered the “base name”, in this case (see picture) this would be “RT-AC1200G+” or “rt_ac1200g_”. I could then enter a new base-name, e.g. “office_router” and the base would have been replaced in all related entities all at once.
Often the base name of sensors and the like is just a seemingly random string anyway that does not make a lot of sense without renaming.
I think this already exists? I use it all the time, unless I’m misunderstanding what you’re asking for.
Go to Devices, pick a device. Click the pencil icon next to the device. Enter a new name, click Update. It will ask you if you want to rename all of the entity IDs, click “Rename” to do so. If the original name of the device has a sub-string match with the entity IDs, it will rename the IDs and their friendly name, according to the new name. Is that what you are looking for?
Note that for some reason this is considered “advanced” functionality, so you must have “Advanced Mode” enabled in your user profile in order to get the entity ID rename prompt. If advanced mode is off, you won’t get the extra prompt.
If I rename the device, then the entities are renamed too.
That is if the entities are still using there autogenerated name.
If I have renamed the entities manually then its not renamed with the device.
Does this take awhile to happen? I bough some WiZ bulbs and have renamed the devices. As initially mentioned, when I changed the device name, I selected “rename” to also rename the device entities. The friendly name of the entities is updating but not the entity_id. I’ve restarted my Yellow a few times now.
I’m having the same issue. Even though clicking ‘rename’ on the Rename all the entities? This will break automations!-question, the entities of some devices refuse to rename.
I thought it could be related to the entities having ‘history’ records (e.g. graphs for temperature etc) but this is wrong. Renaming them one-by-one seems to work.
My other hunch is that this ‘sub-string match criteria’ @freshcoast spoke about does not always work out. For example, one of my devices is called Frient A/S Smoke Sensor SMSZB-120 with entities like sensor.frient_a_s_smoke_sensor_smszb_120_temperature. Perhaps it chokes on the / in that name trying to find entities to rename?
Another device i cant rename ‘all at once’ is called lumi.lumi Weather.
And one that did work was called ‘IKEA of Sweden TRADFRI Remote Control’ without any special characters.
For the cases where the automatic entity_id-renaming via changing the device name does not work, another way to bulk rename entities is to edit some text/yaml files manually.
I don’t know if this has any negative side-effects, but I’ve done this multiple times and have not noticed anything bad. You only lose the entity’s history, but that also happens when auto-renaming via the device name.
Using a method of your choice, get access to the “config” folder (e.g. using the add-on “Samba share” or “Terminal & SSH”)
Open .storage/core.entity_registry in a text editor
Use search and replace to rename your entity.
e.g. I had many lines of this format: "entity_id": "binary_sensor.lumi_lumi_sensor_magnet_aq2_opening",, so I searched for lumi_lumi_sensor_magnet_aq2 and replaced with kitchen_window
If needed, perform the same search and replace on automations.yaml, scripts.yaml, and whatever other yaml files (outside of .storage) you are using the renamed entities in. I usually do a grep/search for the old entity-prefix to find the files I need to modify.
Restart home assistant. I use the shell command ha core restart for this.
I just finish renaming lots of my entities with the “Rename all the entities” feature when renaming a device. I actually had to go through the sources of the frontend to find out, what exactly the “sub-string match criteria” means. So, I thought, I’d come back here and drop a note:
The criterion means that all entities will be renamed, if they (a) belong to the device and (b) contain the slugified device name in their entity id. They will be renamed by replacing the old device name by the new device name. So, some_domain.bla_olddevice_battery_2 will become some_domain.bla_newdevice_battery_2.
I was able to install run this from one of my WSL instances and it works great! Thanks.
I do have one question, trying to run this for a friend of mine who only has access via SSH in HassOS, but doing that reveles that Python is not installed. Is it advisible to install Python3 in HassOS? Any other options?
I’m having this issue, I click on the pencil icon in the device name to rename, but I never get the question to rename all entities at all. Using hass 2024.2.2. Any ideas of what could be wrong? I want to do a mass rename of devices to have a common naming scheme and it would be impossible to do if this doesn’t work. I’d rather not run an “old script posted in the internet” for reliability reasons, don’t want to end up with a messed up installation.
Edit: OK, I see @five5607’s script actually uses the API, it doesn’t mess with the YAML files, so I guess it should be safe, but still if there is supposed to be an official way to do it I’d rather do that.
Sometimes I used to have an issue when trying to change bulk entity ids by changing the device name due to the "Do you also want to rename the entity IDs of your entities?" feature not working. This seems to happen when the device name and the device name portion of the entity id do not match. For anyone running into the same issue the solution is to rename the device name so it matches the device name portion of the entity id and then rename it again the way you want.
Click on one of the device entities and copy the device name portion of the entity id. Ex: In sensor.echo_dot_next_reminder copy the echo_dot portion.
Rename the device to the copied name. Ex: echo_dot.
If you check one of the device entity ids it should now match the device name.
Rename your device again but this time use the name you want.
When you get the prompt "Do you also want to rename the entity IDs of your entities?" make sure you click RENAME.
All of the device entity ids should now include the device name.