States and attributes of the automation itself in blueprints


I have an automation where I use the last_triggered property of the automation itself in a condition template.

{{ state_attr("automation.example_automation", "last_triggered") }}

Now, I want to convert it to a blueprint but I have no idea how to get access to the data of the automation.

This doesn’t work: State Objects - Home Assistant

Error while executing automation automation.test_test: Error rendering title: UndefinedError: 'state' is undefined

Has anyone an idea to get access to this data?

Thanks in advance!

What you want is called the this variable. It represents the automation’s state object.

1 Like

Oh, thanks. My fault! I just try to use the state object. this works perfectly.

Strangely, the variables behave differently in the blueprint than in an automation.
In the automation last_triggered is updated after the call and in the blueprint before. So in the blueprint last_triggered is always the time of the current call and not the last one.

//EDIT: so I found the difference

current trigger: states[this.entity_id].attributes.last_triggered
last trigger: this.attributes.last_triggered