Help to minimize data of value template

Hi
I am trying to display the switches are ON.

I came up with the following which is working but I only need the friendly name and not the rest of info
in order to sent a simple notification to my phone

value_template: >
          {% set switch = states.switch -%} 
          {% set on = switch | selectattr('state','eq','on') | list -%}       
          {{ on }} 
alue_template: >
          [<template state switch.sonoff_10009bd11e=on; rssi=-68, friendly_name=Kitchen Led 2, icon=mdi:led-strip, supported_features=0 @ 2020-05-25T10:27:31.889492+03:00>, <template state switch.sonoff_1000a05283=on; rssi=-66, friendly_name=Kitchen Led, icon=mdi:led-strip, supported_features=0 @ 2020-05-25T10:27:31.326588+03:00>, <template state switch.tradfi_outlet=on; friendly_name=Tradfi outlet @ 2020-05-24T09:37:57.194650+03:00>]

Ideally from the above I would like to get
Kitchen Led
Kitchen Led 2
Tradfri outlet.

Can someone suggest how to proceed?

      value_template: >
        {{ states['light'] | selectattr('state','eq', 'on') | map(attribute='name') | list | join(', ') }}

“name” will return a friendly name if it exists, otherwise entity_id.

1 Like

Thanks Tom_I !