I’ve just been doing a load of yaml for automating joining renaming etc. Expanding on what they offer on the zigbee2mqtt page. I’ll post it all when I’m done:
But is it possible to rename already discovered devices entity_id in HA?
Renaming of friendly_name in devices.yaml is easy and could bу done by several plugins, but how to rename all correspondent entities? I have to rename ~100 entity_id. It is possible via HA UI, but it will take a week to rename, find rename bugs, again rename. May be these IDs are stored in some yaml file and we can perform text replace?
Or devices could be re-discovered without re-pairnig (some of devices are really hard to get).
If you rename a device in HA it will prompt to rename all it’s child entities. Renaming from Z2M will also rename in HA as this pushed out via MQTT.
Renaming by editing files is not possible AFAIK. You could try editing core.device_registry & core.entity_registry but I’m pretty sure some info is in the database too.
As z2m documentation says- https://www.zigbee2mqtt.io/integration/home_assistant.html#im-confused-about-the-different-device-ids-names-and-friendly-names
Home Assistant
device_id
: determined on first discovery of the device, can only be changed via the Home Assistant web interface afterwards. Used to control/read the state from the device (e.g. in automations)
Only names are changed when z2m friendly_name is changed. But I’m looking for option for entity_id bulk change. IDs like
sensor.0x00158d00031e0ab9_battery
sensor.0x00158d00031e0ab9_humidity
globally rename 0x00158d00031e0ab9 with some XYZ.
Change the friendly_name, delete the device in HA, restart zigbee2mqtt. The device will be rediscovered with entities as sensor.friendly_name_battery.
It really works, thanks!