Templating; showing friendly_name instead of entity_id

I have copied a template from https://smarthomepursuits.com/display-offline-unavailable-or-missing-sensors-in-home-assistant/ and it did what it should. It shows unavailable entities.

But I wonder if it is possible to show the friendly name of the entities instead of the entity id. I have tried to understand the template and i have read the docs regarding templating, jinja and yaml but still my skills are low.

So could someone please help me? Thank you in advance.

Here ist the template:

- platform: template
    sensors:
      unavailable_entities:
        friendly_name: Unavailable Entities
        unit_of_measurement: entities
        icon_template: "{{ 'mdi:check-circle' if is_state('sensor.unavailable_entities','0') else 'mdi:alert-circle' }}"
        value_template: >
          {{ states|selectattr('state','in',['unavailable','unknown','none'])|rejectattr('domain','eq','group')
            |rejectattr('entity_id','in',state_attr('group.ignored_entities','entity_id'))|list|count }}
        attribute_templates:
          entities: >
            {{ states|selectattr('state','in',['unavailable','unknown','none'])|rejectattr('domain','eq','group')
                |rejectattr('entity_id','in',state_attr('group.ignored_entities','entity_id'))|map(attribute='entity_id')|list }}

If all those entities actually have a name:

          entities: >
            {{ states|selectattr('state','in',['unavailable','unknown','none'])|rejectattr('domain','eq','group | rejectattr('entity_id','in',state_attr('group.ignored_entities','entity_id'))|map(attribute='attributes.friendly_name')|list }}
2 Likes

Thank you, thats it, now it shows the friendly name.

Could you give me a hint where I could learn more about templates and such things aside from the Home Assistant docs?