Automated Notify script is broke - Trigger error

I have an automation I use to notify me when a door or window is opened. Recently after an update I am getting an error in the script. I am not sure what I need to change to fix the script.

service: notify.mobile_app_charles_iphone_xs
data:
  title: Sensor Opened!
  data:
    priorty: high
    ttl: 0
    color: red
  message: |
    📵 {{ state_attr(trigger.to_state.entity_id, 'friendly_name') }} is Open!

There is a problem with the trigger.to_state.entity_id line.
When I run this I get the following error running action message
Error rendering data template: UndefinedError:‘trigger’ is undefined

Post the entire automation.

- id: Sensor_Opened
  alias: Sensor Opened
  trigger:
  - platform: state
    entity_id:
    - binary_sensor.livingroom_window
    - binary_sensor.office_west_window
    - binary_sensor.office_south_window
    - binary_sensor.bedroom_southeast_window
    - binary_sensor.bedroom_northeast_window
    - binary_sensor.bedroom_south_window
    - binary_sensor.bathroom_south_window
    - binary_sensor.bathroom_window
    - binary_sensor.kitchen_window
    - binary_sensor.garage_door_sensor
    - binary_sensor.garage_north_door
    - binary_sensor.front_door
    - binary_sensor.sliding_door
    - binary_sensor.utility_door
    to: 'on'
  condition:
  - condition: state
    entity_id: person.charles
    state: not_home
  action:
  - service: notify.mobile_app_charles_iphone_xs
    data:
      title: Sensor Opened!
      data:
        priority: high
        ttl: 0
        color: red
      message: '📵 {{ state_attr(trigger.to_state.entity_id, ''friendly_name'') }}
        is Open!

Capture

The error message is telling you that the service call you entered doesn’t exist.

Double check the entity ID of your iPhone and its related services… there have been a few comments here and other forums about them changing recently related to a recent iOS update.

1 Like

Why was the first error message different from the second error message you posted?
Did you change something?

Thanks for the help.
I think my issue was related to the ‘iphone’ ios update issue.
I went into HA app and renamed my phone from ‘iphone’ to its actual name.
Waited a few minutes and everything updated in HA.
Now my sensors are working and triggers are triggering.