๐Ÿ”น Auto-entities - Automatically fill cards with entities

type: custom:auto-entities
show_empty: false
card:
  type: entities
filter:
  template: >-
    {% set ns = namespace(entity_and_area=[]) -%}
    {%- for entity in states.device_tracker -%}
      {%- set entity_id = entity.entity_id -%}
      {%- set area = area_name(entity.entity_id) -%}
      {%- set entity_and_area = ({'entity_id':entity_id,'area':area}) -%}
      {%- set ns.entity_and_area = ns.entity_and_area + [entity_and_area] -%}
    {%- endfor -%}
    {%- set sorted_list = (ns.entity_and_area) | rejectattr('area','eq',none) | sort(attribute='area') -%}
    {{ sorted_list | map(attribute='entity_id') | list }}

Here we have a list of โ€œdevice_trackerโ€ entities (except not assigned to any area) sorted by area.




Will post a list of useful posts (just in case):

list an entityโ€™s attributes

passing options into a conventional entity row:
โ€“ hide a name
โ€“ show an attribute

how to manage a sorting

mass-rename entities

list of batteries

select entities dependently on their attributes

using AND, OR, NOT

card-mod:
โ€“ general schema
โ€“ conditional card_mod
โ€“ glance + card_mod
โ€“ card-mod in a template: one, two, three

button-card in a grid

stack containing cards of different types

graphs in a stack:
โ€“ history-graph
โ€“ mini-graph-card
โ€“ mini-graph-card + template

many graphs in one card

sorted graphs in an apexcharts donut card

multiple-entity-row

dividers between lists
rows separated by dividers
static rows between filtered rows

defining a number of found elements

how to list entities in 2 columns

how to define Markdown cards in auto-entities

areas:
โ€“ sort entities by area
โ€“ a card with entities filtered by some area
โ€“ list lights in some area
โ€“ list of โ€œareaโ€ cards
โ€“ show an Area card for one area_name
โ€“ list of entities except ones not assigned to any area

templated Gauge card

a possible way to easily define templates for cards

how auto-entities work

how to show an alternative card if a filter gives an empty list

4 Likes