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:
automation:
- alias: Anniversary Automation
trigger:
- platform: state
entity_id:
- sensor.anniversary_first_sensor
- sensor.anniversary_second_sensor
- sensor.anniversary_third_sensor
to: '1'
action:
- service: persistent_notification.create
data:
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.
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.
I have the same issue.
How could I test a state via an input_number ?
or
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.
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:
Google led me here when I was trying to find a solution to my issue and I did not find one anywhere else, so I would like to share.
I have an automation which is normally triggered by a device state, but sometimes I trigger it with another automation. My first if condition had a trigger.to_state.state which caused an issue when triggering with another automation.
I solved this by adding a condition to check the trigger platform.
Short code: