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

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 }}
4 Likes

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:

Hello everyone,

great, this is something I’ve been looking for for a while but If I would like to have the “friendly_name”, how do I set it. I’ve tried everything but it won’t work.

Thank you for your response

... | map(attribute="attributes.friendly_name") | ...
1 Like

Hartelijk dank dit werkt perfect.

1 Like

Old post, but how do i make this list vertical?