Notification With Name of Device Tracker

Trying to make this work, the idea is that if anyone comes “home” a notification will get sent two two people with mobil apps but the message will say whom of the 4 are entering the home zone. Currently I get the following error…

Error: Error rendering data template: UndefinedError: ‘dict object’ has no attribute ‘to_state’

I assume it has to do with the format of the message?

alias: Hy Return Home
description: ""
triggers:
  - entity_id: person.hy
    zone: zone.home
    event: enter
    trigger: zone
  - entity_id: person.hr
    zone: zone.home
    event: enter
    trigger: zone
  - entity_id: person.ryan
    zone: zone.home
    event: enter
    trigger: zone
  - entity_id: person.jen
    zone: zone.home
    event: enter
    trigger: zone
conditions: []
actions:
  - action: notify.mobile_app_rk_12_2
    metadata: {}
    data:
      message: "{{ trigger.to_state.name }} is arriving"
  - action: notify.mobile_app_jennifers_iphone_2
    metadata: {}
    data:
      message: Hy Arrived at Home
mode: single

to_state does not exist on that object.
Try to start with just trigger and see what that outputs.

Sorry I don’t follow

You are using the trigger variable wrong. The to_state datum in that variable does not exist for triggers of type event.

Try to System log: Write the contents of the {{ trigger }} variable, and check the log.

Soory noob here, where do I see the logs?

Under Settings, System.

Or use a normal state trigger with the person as the entity and the state as the home zone.

triggers:
  - trigger: state
    entity_id:
      - person.hy
      - person.hr
      - person.ryan
      - person.jen
    to: "home"
2 Likes

Does that populated the trigger object?

Yes it does.

1 Like

Thank you @parautenbach !!!

1 Like