iOS actionable push notification data template help

The following automation, which alerts me with an actionable iOS notification when one of the smoke sensors trips, woks as intended.

- id: smoke_alarm_triggered
  alias: 'Smoke Alarm Triggered'
  trigger:
  - platform: state
    entity_id: binary_sensor.smoke_hall, binary_sensor.smoke_lounge,binary_sensor.smoke_rumpus
    to: 'on'
  action:
  - service: switch.turn_on
    entity_id: switch.siren_inside
  - service: switch.turn_on
    entity_id: switch.strobe_inside
  - service: notify.ios_iphone
    data:
      message: Smoke Alarm has TRIGGERED!!!
      data:
        push:
          badge: 0
          category: "silencealarm"
        action_data:
          entity_id: group.alarm_outputs

However as soon as I add the following template to indicate which sensor has triggered the alarm I get no message:

- id: smoke_alarm_triggered
  alias: 'Smoke Alarm Triggered'
  trigger:
  - platform: state
    entity_id: binary_sensor.smoke_hall, binary_sensor.smoke_lounge,binary_sensor.smoke_rumpus
    to: 'on'
  action:
  - service: switch.turn_on
    entity_id: switch.siren_inside
  - service: switch.turn_on
    entity_id: switch.strobe_inside
  - service: notify.ios_iphone
    data_template:
      message: "The {{ trigger.entity_id.attributes.friendly_name }} Smoke Alarm has TRIGGERED!!!"
      data:
        push:
          badge: 0
          category: "silencealarm"
        action_data:
          entity_id: group.alarm_outputs

Any idea what I am doing wrong? I’ve tried encasing the message in single, double or no quotes without success.
Similarly, using data: instead of data_template: does not work.
Each sensor does have a correctly defined friendly name.
Other’s have indicated the {{ trigger.entity_id.attributes.friendly_name }} works for their notifications.
It may be something blindingly obvious as I am new to this.

1 Like

Maybe

The "{{ trigger.entity_id.attributes.friendly_name }}" Smoke Alarm has TRIGGERED!!!

Try this:

data_template:
      message: "The {{ trigger.to_state.attributes.friendly_name }} Smoke Alarm has TRIGGERED!!!"
1 Like

Awsome! That did the trick thanks Bob.

1 Like

Thanks Bob, I’d been struggling with this for a while too :slight_smile:

1 Like

Way trying something very similar with no luck. For some reason triggering the automation manually in the UI did nothing. Instead I started changing the state of my binary sensor manually from off to on and that made progress. Working code below:

- id: '1576467014166'
  alias: 'Notify critical water leak detected'
  trigger:
  - platform: state
    entity_id: binary_sensor.dishwasher_moisture, binary_sensor.garage_moisture, binary_sensor.guest_bath_sink_moisture,
      binary_sensor.kitchen_sink_moisture, binary_sensor.mstr_bath_sink_moisture
    to: 'on'
  action:
  - service: notify.ALL_DEVICES
    data_template:
      title: "Water Leak Detected"
      message: "{{ trigger.to_state.attributes.friendly_name }}"
      data:
          push:
            sound:
              name: default
              critical: 1
              volume: 0.5