Automation - multiple triggers and templated action - need help

Hi,

I have an automation with multiple triggers. For deciding which action I need to take, I need to check which of the trigger fired the automation, but can’t find a solution. With the code below, while changing the temperature (1st trigger), the {{trigger.to_state.state}} always return the one of the second trigger.

alias: _test
description: >-
  Thermostat_1 is master and updates thermostat_2 if mode or target temperature
  move.
trigger:
  - platform: state
    entity_id: climate.thermostat_salon_1
    attribute: system_mode
    enabled: false
    variables:                                                                        
      triggermsg: set_preset_mode
  - platform: state
    entity_id: climate.thermostat_salon_1
    attribute: temperature
    variables:                                                                        
      triggermsg: set_temperature
condition: []
action:
  - service: notify.admin_phones
    data:
      message: "{{triggermsg}}-{{trigger.to_state.state}}"
mode: single

Any idea of how I could solve this?
thanks.

You can give each trigger an ID. Use ‘Edit id’ on the 3 for menu. Then you can use a Choose action. The condition for each option of the Choose action can be a ‘Triggered by’ and you can select your IDs.

Try googling ‘home assistant trigger ids’ and ‘home assistant automation choose action’

1 Like

Remove this line from the 1st trigger:

    enabled: false

Thanks for spotting this mistake, which at the end made Nash suggestion work :grinning:

Adding an id to each trigger isn’t necessary to fix the problem you described (removing enabled: false is the remedy). You can already distinguish which trigger occurred by the triggermsg variable.