Zigbee2Mqtt friendly name workflow?

I have successfully integrated z2m with Hassio using the addon by Daniel Welch. Everything appears to work fine, except the various names and ids are all hex strings (as expected). This was fine for when I had a couple of devices for testing, but is becoming increasingly problematic as the number of zigbee devices grow.

I’m looking at the friendly name section in z2m’s devices.yaml, but it seems that by the time they appear there it’s all a bit too late as Hassio would have already autodiscovered them. And once Hassio has does that, it appears too late (plus I don’t want to override things that could otherwise be autodiscovered).

I’m fully accepting that the main problem here is my lack of understanding of how all the various IDs and names link together, but unfortunately the crib sheet in the z2m integration page doesn’t do much to clear it up for me (see end of post).

So my general question is: what is the most correct workflow for naming z2m devices auto discovered by hassio, so that I can easily create entities and automations in Node Red etc?

## I’m 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)
* Zigbee2mqtt  `friendly_name` : used to change the MQTT topic where the device listens and publishes to.
* Home Assistant  `name` : name shown in the Home Assistant UI (unless overridden via a  `friendly_name`  in  `customize.yaml` ). If not changed via the Home Assistant web interface, it is equal to the Zigbee2mqtt  `friendly_name` . Is updated if the Zigbee2mqtt  `friendly_name`  changes (requires restart of Home Assistant)
* Home Assistant  `friendly_name`  ( `customize.yaml` ): overrides the name in the Home Assistant web interface.
3 Likes

I was actually thinking the same thing a couple days ago. I haven’t found a solution yet.

Well my interim “solution” is to:

  1. Pair in z2m (and let hassio autodiscover)
  2. Rename friendly names in the z2m config
  3. Delete the MQTT integration
  4. Clear certain topics from the the mqtt broker
  5. Restart
  6. Restart z2m

This seemed to have done the trick but I’m almost certain I’m doing something bad here :wink:

EDIT: it seems updating the devices.yaml and restarting z2m is enough to have the entities and respective ids regenerate, so this is all much easier than I thought.

2 Likes

@sshaikh how do you rename the friendly names? Where is the z2m config in Hass.io addon approach?

I used the configurator plugin at config/zigbee2mqtt/devices.yaml, but I might have changed the defualt path z2mqtt uses for config.

1 Like

Hello, I am running into the same issue.

Since my network has grown to over 30 zigbee devices, I thought it would be helpful to see the actual names in z2m log. As such, I looked up all 0x00158d0002e29db0 type names in /share/zigbee2mqtt/devices.yaml and added the corresponding friendly name such as 'Living dimmer'.

As the original 0x00158d0002e29db0 unfriendly name remains intact, I had expected that Home Assistant would update all entities with the new friendly name in settings>integrations>mqtt and settings>devices.

However, this does not appear to be the case. Instead, all these devices (and I updated all of them, sadly) now show up as unknown. Interestingly enough, I can still control the devices from the overview page, and they respond. But the new state is not reflected in the overview nor anywhere else as far as I can tell.
The new names and actions are showing up as expected in Hass.io>Add-ons>Zigbee2mqtt>log

Do I need to restore the backup from yesterday or is there a way to get the new names to show up around HA as I expected it to work?

1 Like

I can’t help I’m afraid - I thought I knew when Hassio woiuld update but it seems that I still need to remove and reboot and then pray to the heavens for things to take.

It’s increasingly looking like we should not use any friendly names in Z2MQTT and instead set the names as late as possible (ie in Hassio), especially if you want to rename after creating flows and UI items.

Thanks for your reply @sshaikh I appreciate it :slight_smile:
After restoring yesterday’s backup of /share/zigbee2mqtt/devices.yaml and restarting Hass.io>Add-ons>Zigbee2mqtt all my devices work as before again.

As you suggested, it seems that it is best not to touch this devices.yaml file, at least not in this manner.
Perhaps it is possible to edit the file using Zigbee2mqtt Assistant currently being developed by @carldebilly as this has a per device page dedicated to renaming.

This has the notable disadvantage of having to open each device separately and renaming it, but if that does work as expected then it should be worth the effort.

2 Likes

I do it as soon as possible. If I add new devices, I set ‘homeassistant : false’ in zigbee2mqtt configuration.yaml. If everything I wanted to add is added, I change the friendly names in zigbee2mqtt, and then set ‘homeassistant : true’ again.

1 Like

The problem arises when things change (I moved a light switch to a different room, for example).

Again, I think the root issue is my not understanding what all the different IDs are. Hassio seems to have at least 3 on its own!

@iFloris Thank’s for the tip re the assistant. I just installed it and yes, it seems to send renames to the file. That doesn’t fix our issue but it’s a whole lot better than editing the file!

1 Like

Don’t hesitate if you have suggestion to improve this add-on! :slight_smile:

1 Like

Well @carldebilly since you are asking :slight_smile: One thing that would make (my) life easier is if we could use your tool to mass rename devices or if there was a way to quickly edit many device names from the overview page.

You must have a LOT of devices to ask for this :wink: Because renaming dozens of devices will only take few minutes… Designing a tool to mass-rename them would take a lot more time than that.

… or are you renaming them on regular base? :wink:

Thank you very much, I was having the same problem. This made my day

This is super plugin, thank’s!

zigbee2mqtt has the ability to rename devices via MQTT. It automatically changes devices.yaml. So it quite convenient.

My workflow for adding new devices using a friendly name is:

  1. Supervisor -> zigbee2mqtt -> Config -> homeassistant: false -> Save
  2. Restart zigbee2mqtt
  3. Pair new device(s)
  4. Rename device(s), e. g.
    mosquitto_pub -t zigbee2mqtt/bridge/config/rename -m '{"old": "0x001788011038abcd", "new": "dimmer_switch"}'
  5. Supervisor -> zigbee2mqtt -> Config -> homeassistant: true -> Save
  6. Restart zigbee2mqtt
3 Likes

Can you assist on where to input line in step 4? I would like to rename my ikea sensors.

You can do this via CLI if you have mosquitto installed. Alternatively you can send the mqtt command via Dev Tools in HA. The easiest way I’ve found is installing Zigbee2mqtt Assistant and doing if from there.

It would be good if we could disable HA discovery via mqtt. I dont think this is possible yet though

There is a nice HA package on zigbee2mqtt.io