#Accessing trigger entity in automation action

1 messages · Page 1 of 1 (latest)

twin dune
#

I have an automation I'm writing for notifications when my doorball is rung.

I have multiple doorbells, and therefore multiple entity_id's for my trigger.

Is there a way to access which entity triggered in the message so I can specify the message to display? This is what I'm trying to do, but it's giving me the error missed comma between flow collection entries

action:
  - service: notify.mobile_app_my_phone
    data:
      title: "🔔 Doorbell Ringing!"
      message: >-
      {% if trigger.entity_id == 'binary_sensor.front_door_visitor' %}
        "Someone is at the front door!"
      {% elif trigger.entity_id == 'binary_sensor.garage_door_visitor' %}
        "Someone is at the garage door!"
      {% else %}
        "A doorbell is ringing!"
      {% endif %}
barren hawk
#

is that exactly as you have it?
multi line string needs to be indented one further. I.e. everything under message: needs 2 more spaces on the left

#

I'm also not entirely sure whether you want message: >- or message: |, though I think both should work

twin dune
#

Indentation was exactly the problem. Boy I hate whitespace based languages sometimes.