Problem accessing 'trigger.from_state' following datas

Hi,

Another un-understandable (for me) error :
as the code used :

trigger:
    platform: state
    entity_id: light.bureau
    #from: 'off'
    #to: 'on'
  action:
    - service: persistent_notification.create
      data_template:
        message: "c'est le message"
        title: "c'est le titre : {{ trigger.from_state.state }} ...."

I effectivelly get On/off (depending the state …)

I would like to access the friendly_name … with ‘trigger.from_state_friendly_name’
but I get nothing …

I’ve notice that ‘trigger.from_state’ give :

<state light.bureau=on; brightness=137, friendly_name=Bureau, supported_features=33 @ 2020-04-09T12:07:45.141192+00:00> 

with ‘;’ ending light.bureau while others are ending with ‘,’ …

How to access/read ‘friendly_name’ or ‘brightness’ ?

Thanks in advance

To access the friendly name of the trigger entity:

{{ trigger.from_state.name }}

To access the brightness state attribute of the trigger entity:

{{ state_attr(trigger.entity_id, 'brightness') }}

(you can replace brightness with whatever attribute you’re trying to access)

Edit: to clarify, it doesn’t need to be from_state in the first template, it can be different depending on what you’re doing.

1 Like

@Tediore

Thanks !
I confess I’ve not memorized this function
:slight_smile: