thomasloven / lovelace-auto-entities

🔹Automatically populate the entities-list of lovelace cards
MIT License
1.18k stars 111 forks source link

Add new column, or use template AND secondary info? #420

Open ThreepE0 opened 5 months ago

ThreepE0 commented 5 months ago

Is there a way to add a column to each entity or, while using templates instead of "include," is there a way to include "last-changed?"

I'm using this template to strip out "battery" from the entity names. But when I use template instead of include filter, secondary info doesn't work. If I try using both template AND include filter, then the entities are all duplicated.

  type: custom:auto-entities
  card:
    type: entities
    show_header_toggle: true
  options:
    secondary_info: last-changed  
  filter:
    template: >-
      {% for state in states.sensor -%}
        {%- if state.entity_id | regex_match("sensor.*battery*", ignorecase=True) -%}
          {{
            {
              'entity': state.entity_id,
              'name': state.attributes.friendly_name.lower().replace('battery', ''),
            }
          }},
        {%- endif -%}
      {%- endfor %}
  sort:
    method: value
    reverse: true
    numeric: true
outdooracorn commented 4 months ago

Add 'secondary_info': 'last-changed', below the entity and name properties in your template filter :)