Trigger with a variable

hello everyone,

I have the following triggers:

  - trigger: device
    domain: mqtt
    device_id: ec9db1e9c54fcb056ead3e6f4907171c
    type: action
    subtype: arrow_left_click
  - trigger: device
    domain: mqtt
    device_id: ec9db1e9c54fcb056ead3e6f4907171c
    type: action
    subtype: arrow_left_hold
  - trigger: device
    domain: mqtt
    device_id: ec9db1e9c54fcb056ead3e6f4907171c
    type: action
    subtype: arrow_left_release
  - trigger: device
    domain: mqtt
    device_id: ec9db1e9c54fcb056ead3e6f4907171c
    type: action
    subtype: arrow_right_click
  - trigger: device
    domain: mqtt
    device_id: ec9db1e9c54fcb056ead3e6f4907171c
    type: action
    subtype: arrow_right_hold
  - trigger: device
    domain: mqtt
    device_id: ec9db1e9c54fcb056ead3e6f4907171c
    type: action
    subtype: arrow_right_release
  - trigger: device
    domain: mqtt
    device_id: ec9db1e9c54fcb056ead3e6f4907171c
    type: action
    subtype: "on"
  - trigger: device
    domain: mqtt
    device_id: ec9db1e9c54fcb056ead3e6f4907171c
    type: action
    subtype: brightness_move_up
  - trigger: device
    domain: mqtt
    device_id: ec9db1e9c54fcb056ead3e6f4907171c
    type: action
    subtype: brightness_stop
  - trigger: device
    domain: mqtt
    device_id: ec9db1e9c54fcb056ead3e6f4907171c
    type: action
    subtype: "off"
  - trigger: device
    domain: mqtt
    device_id: ec9db1e9c54fcb056ead3e6f4907171c
    type: action
    subtype: brightness_move_down
  - trigger: event
    event_type:
      - deconz_event
      - zha_event
    event_data:
      device_id: ec9db1e9c54fcb056ead3e6f4907171c

is it possible to make a variable of this to be able to use this trigger for different devices? if so, how do I do this?

Thanks for all the comments!

I don’t fully understand your question, but if you want to perform different actions on different devices based on your triggers, then I suggest you do the following:

  • Use TriggerIds in conjunction with Choose Actions.
  • Remove your deconz_event and zha_event triggers - those have absolutely nothing to do with mqtt in the rest of your triggers.
  • Tell us exactly what it is you’re trying to achieve. So far all we know is that you determined you need a variable out of arbitrarily pasted triggers. We don’t know what your goal is. Read this.
  • Also, I would suggest moving from device-based automations to entity-based automations (unless you’re using Zigbee 2Mqtt on the later versions)