How can an automation access its own attributes (self)

I have a blueprint that is used to create 18 automations on one system. I want to write a log file, in which each automation (i.e. the blueprint) identifies itself by its friendly name.
How can I do that?

I think I saw a feature request on this forum for a reference to ‘self’ but cannot find it now. It would be great if I could just write something like {{ self.friendly_name }} but I don’t think that exists now, does it?

The variable this is used for self-referencing. When used in an active automation, it returns the previous state object of that automation.

So you would use this.name or this.attributes.friendly_name.

1 Like

Thanks. Looks like the solution but what do you mean exactly by ‘previous’ state object. Is it not the current one?
Is it documented somewhere?

Automation Trigger Variables

It contains a State Object whose data represents the entity’s current values, meaning the ones the system, in the case of an automation, (or template for a Template Sensor) will (very shortly) overwrite with new values. That’s why it’s often referred to as being the “previous” state object.

1 Like

Maybe “previous” isn’t the best word to use… it’s the state object of the automation at the time of the trigger event.

You can inspect the values of this for any run of an automation in its trace by selecting the Step Details tab and Changed Variables sub-tab:

1 Like