Auto entities customize displayed name and use attribute as secondary info

I have WHOIS integration with a couple of domains I own.
I’d like to use auto-entities card to display list of domains and order them by expiration date.

I was able to do this using:

type: custom:auto-entities
card:
  show_header_toggle: false
  title: Domeny
  type: entities
  unique: true
  show_empty: true
filter:
  include:
    - integration: whois
      entity_id: sensor.*_days_until_expiration
      options:
        secondary_info: last-changed
sort:
  method: state

but this gives me those ugly names (sensor names):
image

I did a second version using a template:

type: custom:auto-entities
card:
  show_header_toggle: false
  title: Domeny
  type: entities
  unique: true
  show_empty: true
filter:
  template: >-
    {% set DOMAINS = states.sensor | selectattr('entity_id', 'in',
    area_entities('Biuro')) -%}

    {%- for domain in DOMAINS if
    (domain.entity_id.endswith('_days_until_expiration')) -%}
      {%- set NAME = domain.entity_id -%}
      {%- set DOMAIN_NAME =  NAME.replace('_days_until_expiration','').replace('sensor.','').replace('_','.') -%}
      {%- set EXPIRES =  domain.attributes.expires -%}
      {{
        { 'entity': NAME,
          'name': DOMAIN_NAME,
          'secondary_info': 'EXPIRES'
        } }},
    {%- endfor %}
sort:
  method: state

and this looks better (I see proper domain names):
image

But I’m trying to add the actual expiration date in the secondary info.
How can I do that?
In the first version I used the secondary_info option, but it shows me the last update value, not the attribute that I want.

My questions are:

  1. How can I change the displayed name of the entity in the first version? (I prefer it because it looks simpler and I don’t need jinja template for it)
  2. How to use attribute from my entity as a secondary info
  3. How to filter by integration in the template in version two.
    {% set DOMAINS = states.sensor | selectattr('entity_id', 'in', area_entities('Biuro')) -%}
    here I’d like to add a filter to include only sensors from whois integration

I was able to achieve the desired functionality and look using lovelace-template-entity-row and using this card configuration:

type: custom:auto-entities
card:
  show_header_toggle: false
  title: Domains - days until expiration
  type: entities
  unique: true
  show_empty: true
filter:
  include:
    - integration: whois
      entity_id: sensor.*_days_until_expiration
      options:
        type: custom:template-entity-row
        state: >-
          {% if is_state("this.entity_id", "unknown") %} - {% else %} {{
          states("this.entity_id") }} d {% endif %}
        name: '{{device_attr("this.entity_id", "name")}}'
        secondary: >-
          Expires: {{ as_timestamp(state_attr("this.entity_id","expires")) |
          timestamp_custom("%y-%m-%d %H:%M") }}
        color: '{% if states("this.entity_id") | int < 20 %} red {% endif %}'
sort:
  method: state

Not sure if this is the best (optimal) way to do this, but it works.
Input and improvement are welcome.

Great thanks for the idea!!
I was looking for solution to make an automated list of installed addons with versions.
And with your approach I cam make exactly what I want )

Maybe it will be useful for someone.
List of installed addons

  • with device pictures (not icons)
  • without annoying “Update” (name was taken from corresponding device)
  • with installed version on the right side instead of useless ‘no update’-like info
card:
  type: entities
  title: Addons versions
  icon: mdi:toy-brick-outline
  show_header_toggle: false
filter:
  template: >-
    {% set STATES = states | selectattr('entity_id', 'in',
    integration_entities('hassio'))  -%}

    {%- for STATE in STATES 
      if(STATE.entity_id.endswith('_update')) -%}
      {%- set ENTITY_ID = STATE.entity_id -%}
      {%- set DEVICE_NAME = device_attr(STATE.entity_id, 'name') -%}
      {{
        { 'entity': ENTITY_ID,
          'name': DEVICE_NAME,
          'type': 'attribute',
          'attribute': 'installed_version'
        } }},
    {%- endfor %}
  exclude:
    - name: Home Assistant Core*
    - name: Home Assistant Supervisor*
    - name: Home Assistant Operating System*
sort:
  method: name