Enumerate all entity_ids of light domain to show all lights that are currently on using entity-filter card

Tags: #<Tag:0x00007fc409464540> #<Tag:0x00007fc409464478>

Hi,
I am trying to add a card to the UI, that shows all lights that are currently on (could also be "all open windows,…).

I can achieve this simply by using the entity-filter card and manually adding a list of all my light entities. But I thought, there must be a more elegant and future-proof way. What I really want to spefify is “all entities of the light domain”.
The forum posts PSA: Turn on/off all lights in Home Assistant 0.104+ (group.all_* changes) and How to say in message which windows are open? contain template code that can be used in automations, but I can’t get this to work for the entity list in the entity-filter card.

What I tried:

type: entity-filter
card:
  type: glance
  title: Active lights
show_empty: false
state_filter:
  - 'on'
entities: > 
  {% set domain = 'light' %}
  {% set entities = states[domain] | map(attribute='entity_id') | list %}
  {{entities}}

and

type: entity-filter
card:
  type: glance
  title: Active lights
show_empty: false
state_filter:
  - 'on'
entities: > 
    {% for state in states.light %}
    - {{ state.entity_id }}
    {% endfor %}

Both without success - probably because jinja templates are not allowed for entities:

Any advise is greatly appreciated :slightly_smiling_face:

Use the auto-entities card.

Or stay with standards:

{{ states.light | selectattr("state","eq","on") | map(attribute="entity_id") | list }}

That doesn’t change the fact that you can’t use templates with the filter entity card

1 Like

True. Didn’t see that.

Thank you for the quick replies. While I would hope that this is possible with vanilla home-assistant in the future, similar to how automations already allow to use templates to list entities, it is great that someone already invented the auto-entities card :slight_smile: