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

Hi, this is my first post, and first I will thank you all for HA, and the great community and help that is provided here, in other threads.

I am totally a newbie, I am starting with some automations, and I’ve been playing with the HACS integratiosn, Anniversaries and Garbage and I am testing with some dates to be notified about, and instead of creating an automation for every date, I am trying to do it all in one.

This is what I am tested, that I’ve seen in the author’s github:

  - alias: Anniversary Automation
    - platform: state
        - sensor.anniversary_first_sensor
        - sensor.anniversary_second_sensor
        - sensor.anniversary_third_sensor
      to: '1'
      - service: persistent_notification.create
          message: '{{trigger.to_state.attributes.friendly_name}} is tomorrow!'

But that returns the error:

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

I’m using telegram notify service but I imagine is doesn’t matter.

I search many threads, but it’s no working any of the solutions posted.

Any help would be really appreciated.

Thank you.

1 Like

I’m guessing you’re triggering this from the UI? If yes, that will error because there’s no trigger. Wait for the automation to occur naturally or use a test entity to trigger the automation.

You can use an input_number helper as a test entity.

1 Like

Oh my god… It was that…

I’ve tested it with developer options and the notification show up…

Thank you!


it bites everyone new :wink:

You should be proud that you created a template that actually works without needing to post. That’s a feat on it’s own.


Hallo Gents,

I have the same issue.
How could I test a state via an input_number ?


please check why the below codes are not working.
If I unplug a device, no error messages in the log, but no message arrives.
Mail sending is working from powershell and from developer tools as well.

- id: notify_on_device_offline
  alias: "Device offline notification"
  mode: parallel
    - platform: state
        - fan.air_purifier
        - sensor.smart_air_box_3_temperature
        - sensor.smart_air_box_2_temperature
        - sensor.smart_air_box_1_temperature
        - binary_sensor.zigbee_magnetic_sensor_1
        - binary_sensor.zigbee_magnetic_sensor_2
        - sensor.z_stick_gen5_usb_controller_node_status
      to: "unavailable"
        minutes: 5
    - service: notify.mail_xxxsomethingxxx
        title: "Device offline!"
        message: >
          '{{ trigger.to_state.attributes.friendly_name }} offline more than 5 minutes!'
          "[email protected]"

###in configuration.yaml
  - name: "mail_xxxsomethingxxx"
    platform: smtp
    server: ""
    port: 587
    timeout: 35
    sender: "[email protected]"
    encryption: starttls
    username: [email protected]
    password: xxxsomethingpasswordxxx
      - "[email protected]"
    sender_name: "HA"

Did you read the thread? Are you pressing the button in the UI to trigger it? If the answer is yes, that will always error out because there is no trigger object. You have to wait til the trigger fires. See the solution: