How to get friendly_name from trigger.platform: event

Hello all,

Please help me, how to get “friendly_name”?

My below code get “entity_id”:

- alias: Notify iOS myPhone  
  trigger:
    platform: event
    event_type: call_service
    event_data:
      domain: switch
      service: turn_on 
  action:
    service: notify.ios_myphone
    data_template:
      message: >
         {{ trigger.event.as_dict().get('data').get('service_data').get('entity_id') + "was on." }}

Something like this should work:

{{states.switch['switch.test'.split('.')[1]].attributes.friendly_name}}
1 Like

Thank you for your reply.

I want to get “friendly_name” of any “entity_id” from domain “switch” if it triggered by platform: event.
And i don’t want to list all of them (switch.entity_id) into trigger.

If get friendly_name of trigger list, i got it.

' {{ trigger.to_state.attributes.friendly_name }} was {{ trigger.to_state.state }} '