Maybe a stupid question

Hya,

more than once i’ve found trigger.from_state.attributes.friendly_name in examples and guides.

What the explanation for this, how does it works?

Thx in advance.

It get’s the friendly name of the entity id that triggered the automation.

See here for more info of the trigger variables → Automation Trigger Variables - Home Assistant

Actually, trigger.from_state.name would be more efficient as it will get the friendly name and if the friendly name doesn’t exist, it defaults to the entity_id.

And a better option is: trigger.from_state.name which will return the entity_id if the trigger entity has no friendly_name.

Isn’t name a variable of the state object directly, instead of the state_objects attributes?

1 Like

Yeah it is. Fixed.

1 Like