'dict object' has no attribute 'device_tracker'

Which error do I make with the configuration, because I receive the following error message:

Error rendering data template: UndefinedError: 'dict object' has no attribute 'device_tracker'

How can I fix this?

- id: '1525596790130'
  alias: 'Update notifications'
  trigger:
    platform: state
    entity_id: updater.updater
  action:
    service: notify.telegram
    data_template:
        title: "Smarthome Update Info" 
        message: "Home Assistant {{ states.updater.updater.state }} is now available. {{now().strftime('%Y-%m-%d %I:%M %p')}}"

- id: '1525596790128'
  alias: 'Mobile HomeIn'
  trigger:
    platform: state
    entity_id: device_tracker.env_handyreni, device_tracker.env_handypeter2, device_tracker.env_handytina
    from: 'not_home'
    to: 'home'
  action:
    service: notify.telegram
    data_template:
      title: "Smarthome Info" 
      message:  > 
         "{{  trigger.device_tracker.attributes.friendly_name  }} ist zu Hause."


- id: '1525596790129'
  alias: 'Mobile HomeOut'
  trigger:
    platform: state
    entity_id: device_tracker.env_handyreni, device_tracker.env_handypeter2, device_tracker.env_handytina
    from: 'home'
    to: 'not_home'
  action:
    service: notify.telegram
    data_template:
      title: "Smarthome Info" 
      message:  >
         "{{  trigger.device_tracker.attributes.friendly_name  }} verläßt das Haus."
		 

This is causing your problem.

your trigger is a state trigger. State triggers only have a few attributes.

Template variable Data
trigger.platform Hardcoded: state
trigger.entity_id Entity ID that we observe.
trigger.from_state The previous state object of the entity.
trigger.to_state The new state object that triggered trigger.
trigger.for Timedelta object how long state has been to state, if any.
      message:  >
        {{  state_attr(trigger.entity_id, 'friendly_name')  }} verläßt das Haus.

should work

EDIT: Fixed @lolouk44 typo

Thanks for the help, but if I apply this, then I get the following error.

Log Details (ERROR)
Thu May 10 2018 14:43:38 GMT+0200 (CEST)
Error rendering data template: UndefinedError: 'states_attr' is undefined

Modified configuration

- id: '1525596790129'
  alias: 'Mobile HomeOut'
  trigger:
    platform: state
    entity_id: device_tracker.env_handyreni, device_tracker.env_handypeter2, device_tracker.env_handytina
    from: 'home'
    to: 'not_home'
  action:
    service: notify.telegram
    data_template:
      title: "Smarthome Info" 
      message: "{{  states_attr(trigger.entity_id, 'friendly_name')  }} verläßt das Haus."

Home Assistant - Version 0.68.1

Typo, it’s state_attr without the ‘s’

1 Like

ooops, now it works perfectly. Many thanks for the help.:smile:

Credits go to @petro for the initial answer, I can’t accept them for just removing an ‘s’ :smiley:

1 Like