Automation: Pull through trigger into output?

Evening All,

I have an automation for each door, window and motion sensor that I have which logs to a google sheet using ifttt. I’m using mutiple triggers in one automation and I want pull through the friendly_name field into the google sheet. I know I can use :

{{states.binary_sensor.SENSOR.attributes.friendly_name}}

However without creating an automation for each sensor is there a way I can pull through which ever trigger was activated and stick it where the “SENSOR” is above?

trigger.to_state.attributes.friendly_name

1 Like

I use this for notifications but I don’t see why it shouldn’t work for IFTTT as well:

- alias: etekcity switch triggers etekcity script on
  trigger:
    - platform: state
      entity_id: switch.etekcity_0305_1, switch.etekcity_0305_2, switch.etekcity_0305_3, switch.etekcity_0305_4, switch.etekcity_0305_5, switch.etekcity_0315_1, switch.etekcity_0315_2, switch.etekcity_0315_3, switch.etekcity_0315_4, switch.etekcity_0315_5, switch.etekcity_0320_1, switch.etekcity_0320_2, switch.etekcity_0320_3
      from: 'off'
      to: 'on'
  action:
    - service: script.turn_on
      data_template:
        entity_id: script.{{ trigger.from_state.entity_id[7:] }}_on
    - service: notify.mypushbullet
      data_template:
        title: "Home Assistant says:"
        message: '{{ trigger.from_state.name }} = {{ trigger.from_state.entity_id[7:] }} switched on @{{now().strftime("%H:%M")}}h!'

image

1 Like

Thanks works a treat.

1 Like

And thank you.

1 Like