MQTT device trigger: Need a template to reference certain trigger in "wait _for_trigger"-block

Hi there, I am fairly new to HA and have always managed to find what I’m looking for in the community posts…until now. I’d really appreciate help on this template I’m trying to create. It is supposed to reference one of two triggers I want my automation to wait for, in order to decide how to proceed. If I double press button no2, I want the automation to stop. If I single press button no1, I want it to continue before the timeout. At the moment, it continues with both triggers.

I have read through quite a few topics and documentation and tried many different combinations, but cannot find anything that works for my use case.

For reference, among other stuff, I have looked at this post as well as the trigger variables and MQTT device trigger documentation. My trigger yaml looks different though and have no idea if it’s even possible to reference the subtype.

This is the relevant yaml snippet :

      - wait_for_trigger:
          - domain: mqtt
            device_id: 6ce568a8659cae6362c3e45
            type: action
            subtype: 2_initial_press
            trigger: device
          - domain: mqtt
            device_id: 6ce568a8659cae6362c3e45
            type: action
            subtype: 1_short_release
            trigger: device
        timeout:
          hours: 0
          minutes: 5
          seconds: 0
          milliseconds: 0
      - choose:
          - conditions:
              - condition: template
                value_template: "{{ wait.trigger.device.subtype == '2_initial_press' }}"
            sequence:
              - stop: Cancel automation
          - conditions:
              - condition: template
                value_template: "{{ wait.trigger.mqtt.subtype == '1_short_release' }}"
            sequence: []

Thanks in advance!

Device Triggers don’t really have their own trigger variable values, they inherit them from the underlying automation trigger type… so , neither wait.trigger.mqtt.subtype nor wait.trigger.device.subtype are probably valid variables.

I’ve never used an MQTT Device Trigger, so my advise would be to set up a basic automation that uses one for its trigger and then look at the debug trace to see what values are present in the normal trigger variable. My guess would be that it will follow the MQTT trigger’s variable schema and you will need to use the payload and/or topic properties.

Thank you so much for your answer! I did go into debug and saw how the trigger action is displayed and it was simpler than I thought: wait.trigger.payload

I know I had even played around with .payload as per mqtt trigger documentation but I think I had always added something I shouldn’t have. Anyway, thanks for your tip, it works now!

(Also accidentally found out that, if you click on the orange bar that pops up whenever a trigger is registered, it gives you the info I needed!)