How to use mqtt device as blueprint input? How do I get a customable discovery id?

Hey guys,

I have a question, I get stuck over and over again and don’t find a solution, even not with the official documentation.

I want to change an automation to a blueprint. In my automation I use as trigger devices

trigger:
  - platform: device
    domain: mqtt
    device_id: 7b355db79f6c0c795eec22734e49c750
    type: action
    subtype: "on"
    discovery_id: 0x84ba20fffec79587 action_on
  - platform: device
    domain: mqtt
    device_id: 7b355db79f6c0c795eec22734e49c750
    type: action
    subtype: brightness_move_up
    discovery_id: 0x84ba20fffec79587 action_brightness_move_up
  - platform: device
    domain: mqtt
    device_id: 7b355db79f6c0c795eec22734e49c750
    type: action
    subtype: "off"
    discovery_id: 0x84ba20fffec79587 action_off

Now I want to use the device option as input in a blueprint. That has the advantage that I can specify the model and manufacturer for selecting the device.
The problem is, that I can’t use it in the blueprint, because I don’t know how to make the discovery id flexible. The test blueprint is only usable with the one button with that discovery id.

The blueprint looks for testing like that:

blueprint:
  name: Test
  description: This blueprint is for test
  domain: automation
  input:
    button:
      name: button
      description: Choose Button
      selector:
        device:
          manufacturer: IKEA
          model: TRADFRI shortcut button (E1812)
          multiple: false

mode: restart
max_exceeded: silent
trigger:
  - platform: device
    domain: mqtt
    device_id: !input button
    type: action
    subtype: "on"
    discovery_id: 0x84ba20fffec79587 action_on
    id: "on"
  - platform: device
    domain: mqtt
    device_id: !input button
    type: action
    subtype: brightness_move_up
    discovery_id: 0x84ba20fffec79587  action_brightness_move_up
    id: "long"
  - platform: device
    domain: mqtt
    device_id: !input button
    type: action
    subtype: "off"
    discovery_id: 0x84ba20fffec79587  action_off
    id: "off"

For now I use as trigger the state instead of device, but with that I don’t know how to specify the selector, so that it only shows entites from e.g. IKEA?

Maybe someone can help me with that or just tell me, that it’s impossible in the moment.

Thanks a lot.

1 Like

Hi @Danieldz,
Did you ever find out how to get the discovery_id from within the blueprint.
This is exactly what I am trying to do. I’ve just spent the last two days migrating away from ZHA to Zigbee2mqtt because of a umber of other reasons and this evening I’ve just discovered that I am unable to get my blueprints working because there appears to be no way to use matt device triggers in blueprints :frowning:

1 Like

I’m in the same situation. The first part of the discorvery_id is the same as the device ID in the Zigbee2mqtt configuration.yaml. But how to get that, no idea!

Hi @bvhme,

I figured out a way around the discovery_id issue. See my GitHub post here: HomeAssistant: recommended trigger handling · Koenkk/zigbee2mqtt · Discussion #6013 · GitHub

It’s a bit of a kludge, but at least it allows you to create blueprints using MQTT based zigbee devices.

I’ve found zigbee2mqtt to be so much more reliable and easier to maintain than ZHA, that it is worth the effort.

1 Like

Has anyone had success with getting discovery_id inside a blueprint?
I’m moving away from ZHA to Z2M and want to change some of my blueprints, so I’d like to use a device selector to pick the correct one. The selector is the easy part, but I don’t know how to get discover_id, because the trigger doesn’t work without it.