Lampie: Notifications on Multiple Switches for Home Assistant

They are not the same, rohan’s will output the name of the switch

{{ device_attr('light.kitchen', 'name') }}

Kitchen

My code outputs the Z2M identifier

{{ device_attr('light.kitchen', 'identifiers') }}

[
  [
    "mqtt",
    "zigbee2mqtt_0x9400000000000066"
  ]
]

Then I split the second value to get the ID.
You can publish to either the name of the device or the ID to MQTT.

zigbee2mqtt/{device_id}/set
zigbee2mqtt/{name}/set

Using the name from HA will work most of the time. The reason I changed to use the identifier is because you can have a different name in HA and it if it doesn’t match the name in Z2M then the path with the name will not work.

How I came across this issue is because one of the people that used my blueprint had one name set in HA as “Living Room West Light” and a path name set in Z2M as “living_room/lights/west_light” so Z2M would expect the publish path would be zigbee2mqtt/living_room/lights/west_light/set but the publish path with the identifier still worked.

However, if you can get the command_topic from the MQTT config of the device then none of this matters as you will have the correct path anyway.