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.
This seemed to have done the trick but I’m almost certain I’m doing something bad here
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.
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?
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
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.
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.
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!
Well @carldebilly since you are asking 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 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.
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.