Closed hvanoch closed 4 years ago
The 0x00158d00053f84dc
part of binary_sensor.0x00158d00053f84dc_contact
is taken from the friendly_name
in the Zigbee2MQTT configuration.yaml
. However this is only set once! When the friendly_name
is updated and Zigbee2mqtt resend the discovery payload, Home Assistant does not update the entity_id.
So the options are:
friendly_name
by either:
homeassistant: false
in Zigbee2MQTT configuration.yaml
, start, pair device, stop and set homeassistant: true
again.Thank you for the clear explanation. Guess it makes sense it doesn't update the entity_id by itself.
If I get annoyed by this then I guess I might make a script that changes the entity_id in the config/.storage/core.entity_registry
with some regex whenever I do a rename of a zigbee device through ha.
I was trying to find an easy way to also change HA's entity_id for some time as well and reading your issue, I think I found another option: If you actively delete all of the device's entities from Home Assistant before you rename, HA will accept the new name also as the entity_id (and not the friendly name only).
Deletion should be done via MQTT also (publish an empty payload to all config topics) and I found a relatively easy way to do this here (picture taken from there also):
So the complete procedure would be:
homeassistant/sensor/<device_id>/action/config
, homeassistant/sensor/<device_id>/battery/config
, homeassistant/sensor/<device_id>/linkquality/config
, homeassistant/binary_sensor/<device_id>/update_available/config
etc. - you can get this information from the z2m log right after pairing) using MQTT as shown above.@Koenkk Maybe z2m could delete the entities from HA first, wait a few seconds and then publish the new name when renaming a device? This way it could work seamlessly at least as long as Home Assistant is running while renaming...
Edited to use device_id instead of friendly_name.
@felixstorm good idea! implemented
Ohhhh thats why my devices got renamed automatically and i was needed to rename them back manually...great
@felixstorm good idea! implemented
can we have some kind of a switch on that? entity_id and friendly name little bit different and this kind of "enhancements" can and would ruin all the existing logic in HA
can we have some kind of a switch on that?
+1 I like my 0x entities!
@Koenkk Technically, recreation of ha entities is a possible solution. But one should have choices either to recreate entities automatically or do it manually (current deconz logic, for example), since automatic deletion of entities could be very damaging for existing legacy in the ha, such as automations, lovelace, etc.
What's the status on this? Does it only change entity id when I change the friendly name? Or will it also change entity id of devices I already renamed in the past?
Because although I hate the 0x entity id's and manually renamed most, the key is most... I would hate it even more if current automations en cards stop working with this update... 🙄
I've updated the behaviour:
configuration.yaml
(stop/start z2m) -> no rediscover, was already the casezigbee2mqtt/bridge/config/rename
) -> no rediscover anymore zigbee2mqtt/bridge/request/device/rename
) -> by default no rediscover anymore but it can be enabled by publishing: {"from": "oldname", "to": "newname", "homeassistant_rename": true}
And if you rename through the devices.yaml? (Which I used to do...)
That is the same as:
When renaming to configuration.yaml (stop/start z2m) -> no rediscover, was already the case
Thanks!
Good and a shame at the same time. 😛 So what would be the easiest way to rename the friendly names and entities? Or should I just wait for something like Z2M Assistant to support it?
Yes, or the recently integrated frontend (https://github.com/Koenkk/zigbee2mqtt/issues/4266) (homeassistant_rename
option will be added soon there).
Sounds great! Thanks!
I've updated the behaviour:
- When renaming to
configuration.yaml
(stop/start z2m) -> no rediscover, was already the case- When renaming through the old api (
zigbee2mqtt/bridge/config/rename
) -> no rediscover anymore- When renaming through the new api (#3281) (
zigbee2mqtt/bridge/request/device/rename
) -> by default no rediscover anymore but it can be enabled by publishing:{"from": "oldname", "to": "newname", "homeassistant_rename": true}
thanks a lot, Koen! will wait for the next update to install.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days
This works almost...
Living Room - door sensor in ZigBee2MQTT
Change name in Home Assistant to Door Sensor
Then I change in ZigBee2MQTT to Sensor Door and disable change in Home Assistant
I get link quality, contact and battery to change their names.
any chance we can have a setting to auto tick the "Update Home Assistant entity ID" option when renaming devices? I'm migrating from deconz to z2m and It's pretty anoying that I have to check this option every time I rename a devices friendly name :). Otherwise I'm very happy with Z2M so far 😃
edit: also, just ticking the option "Update Home Assistant entity ID" to get the friendly name pushed gives the error that the friendly name is already in use. Although I understand the error, perhaps this can be fixed so we can more easily push a new friendly name (in case the option to update HA entity id was not ticked) instead of renaming, and renaming again with the option ticked?
Can this option be set in the yaml config for a device?
Hi,
Just starting with integrating the zigbee2mqtt in my home assistant setup. Everything in home assistant has to be referenced with an enity_id.
When using home assistant and zigbee2mqtt with discovery all entities get a name like
binary_sensor.0x00158d00053f84dc_contact
What are the possible ways to change this entity ID. Is this only through the UI or is there also a way to do it through some configuration (either in the home assistant or in the zigbee2mqtt)? That way I can put it my source control. It would also be a lot easier to search.
What would you advice?