Device properties used in blueprint trigger

I’m working on setting up a blueprint to handle Sonoff Zigbee buttons. To know which button is being pressed I used the “unique_id” in the event data and I just hardcoded that and everything worked great. Trying to make a blueprint around this and figuring out what the unique_id is seems to not be possible.

I’m getting the device using a device selector

input:
    button:
      name: Button
      description: The button to configure.
      selector:
        device:
          manufacturer: eWeLink
          model: WB01

In the variables I’m trying to convert from the device id that is provided by the input to the unique_id I need

variables:
  button: !input 'button'
  zigbee_id: "{{ button['IEEE'] }}:1:0x0006"

Then triggering using the unique_id of the event_data to ensure it is the button I’m looking for

trigger:
- platform: event
  event_type: zha_event
  event_data:
    endpoint_id: 1
    unique_id: '{{ ''zigbee_id'' }}'

Anyone know how I could get this property to build the unique_id?
image

2 Likes

I was trying to do this exact thing with a Linkind button. It looks to me like it’s not possible at the moment. Here’s the relevant snippets from a blueprint config for what we want:

blueprint:
  input:
    button_device:
      name: Button Device
      selector:
        device:
          manufacturer: lk

trigger_variables:
  device: !input button_device
  ieee: "{{(device_attr(device, 'identifiers')|list)[0][1]}}"

trigger:
  platform: event
  event_type: zha_event
  event_data:
    device_ieee: "{{ieee}}"

The problem is that device_attr is not available in limited templates. :frowning_face:
It really seems like this should be possible, but I can’t figure an actual way. I think the workaround is to make the input for the zigbee identifier, instead of for the device, it’s just super unfriendly.

(On a side note, having the identifiers attribute of a device be a set, rather than a dictionary is pretty unfriendly as well. It means you have to turn it in to a list to even be able to grab one of the identifiers in a template)

1 Like