Optimize template for all valid entities

HI,

a little script to welcome me home:

arrive_home:
  alias: Arrive Home
  sequence:            
    #- service: switch.turn_on
    #  entity_id: switch.pc_me_monitor
    - service: light.turn_on
      entity_id: light.kist
    - service: light.turn_on
      entity_id: light.drawer
    #- service: script.mp_radio
    - service: notify.notify
      data_template:
        title: " Arrived Home at 
        {{ as_timestamp(states.automation.arrive_home.last_updated)
         | timestamp_custom ('%H:%M') }}"
        message: "Je bent thuis, het script werkt en 
        {{states.light.kist.attributes.friendly_name}} en 
        {{states.light.drawer.attributes.friendly_name}} heb ik voor je aangezet."

Would it be possible to have the message template show the friendly names of the turned on lights , without hardcoding their names (as stated in the services? Would make it much easier to change the script and not have to worry about changing all entities everywhere.

translation:

message: “You’ve arrived home at [time], script is working fine and I’ve turned on
{{states.light.kist.attributes.friendly_name}} and
{{states.light.drawer.attributes.friendly_name}} for you.” :wink:

I know you can grab the friendly_name of the entity_id that triggered an automation :

message: '{{ trigger.to_state.attributes.friendly_name }} is on'

But I’ve not seen an equivalent in a script

Another way to do it would be to use the ‘For Loop’ example in under Developer Tools : Template

This satisfies your wanting not to hardcode entity_id’s, but has the possibly unwanted affect of listing the state of ALL your lights.

thanks,
along the lines, you’re describing one of my other wishes: have a group_lights on with all lights on… Still not able to make that work… duh