Multiple triggers how to distinguish them in the conditions?

Hi,
I have the following automation running / working:

alias: set_wb_16a
description: ""
trigger:
  - platform: mqtt
    topic: pv/HM1500/ch0/P_AC
condition:
  - condition: template
    value_template: "{{ trigger.payload | float(0) > 800 }}"
action:
  - service: mqtt.publish
    data:
      qos: 0
      retain: false
      topic: wallbox/999999/command
      payload: maxCurrent 16
mode: single

Now I want to add another trigger and an AND condition. So far so good but how to distinguish the two triggers in the condition? Is there some kind of trigger1.payload and trigger2.payload or is the first condition for the first trigger and so on?

Kind regards
gerddasboot

You can define an ID for each trigger that you can then use in conditions later on.

The available payload and other information depends on the trigger type.

No, it’s trigger.payload in both cases.

No, all conditions are evaluated and have to be true for the automation ton continue.

Thank you. I must have missed this in the documentation.
But it seems not to work or I do not understand the documentation.

alias: set_wb_16a_PLAY
description: ""
trigger:
  - platform: mqtt
    topic: pv/HM1500/ch0/P_AC
    id: event_1_trigger
  - platform: mqtt
    topic: wallbox/999999/maxCurrent
    id: event_2_trigger
condition:
  - condition: and
    conditions:
      - condition: template
        value_template: "{{ event_1_trigger.payload | float(0) > 300 }}"
      - condition: template
        value_template: "{{ event_2_trigger.payload | float(0) == 32 }}"

Results in:

Executed: March 29, 2023 at 12:55:26 PM
Error: In 'and' (item 1 of 2): In 'template' condition: UndefinedError: 'event_1_trigger' is undefined In 'and' (item 2 of 2): In 'template' condition: UndefinedError: 'event_2_trigger' is undefined
conditions/0
Executed: March 29, 2023 at 12:55:26 PM
Error: In 'template' condition: UndefinedError: 'event_1_trigger' is undefined
conditions/1
Executed: March 29, 2023 at 12:55:26 PM
Error: In 'template' condition: UndefinedError: 'event_2_trigger' is undefined

I think I missed something… again.

You can access the id like this:

condition:
  - condition: template
    value_template: "{{ trigger.id == 'event_1_trigger' }}"

And the payload is always available as trigger.payload .

I think in your particular case you probably want to skip the conditions the way you have defined them because all conditions must be true to execute the actions. More suitable is the option to add conditions to the actions like this:

trigger:
  - platform: mqtt
    topic: pv/HM1500/ch0/P_AC
    id: event_1_trigger
  - platform: mqtt
    topic: wallbox/999999/maxCurrent
    id: event_2_trigger
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: event_1_trigger
          - condition: template
            value_template: "{{ trigger.payload | float(0) > 300 }}"
        sequence:
          - service: mqtt.publish
            data: ...
      - conditions:
          - condition: trigger
            id: event_2_trigger
          - condition: template
            value_template: "{{ trigger.payload | float(0) == 32 }}"
        sequence:
          - service: mqtt.publish
            data: ...

Yes this seems to be the solution. And yes skipping the condition and let the magic happen in the action seems to be way better.