Using labels for conditional cards

On my dashboard I want to show all the lights that are on so it’s easy to turn them off but I don’t want a static element there all the time. I’ve got it to work with a entity-filter card but it’s very manual and any time I add new lights I would need to edit this. I’m wondering if there is a way to use labels or something similar so I can configure it the entity-filter to be when any entity in that label is ‘on’

Here is what I have currently

title: Lights on
entities:
  - entity: light.front_door_panel_center
    type: custom:mushroom-light-card
    layout: vertical
    name: Chandelier
  - entity: light.front_door_panel_top
    type: custom:mushroom-light-card
    layout: vertical
    name: Front Door
  - entity: light.front_door_panel_bottom
    type: custom:mushroom-light-card
    layout: vertical
    name: Hallway
  - entity: light.garage_light
    type: custom:mushroom-light-card
    layout: vertical
    name: Garage
  - entity: light.laundry_light_panel_bottom
    type: custom:mushroom-light-card
    layout: vertical
    name: Kitchen
  - entity: light.laundry_light_panel_top
    type: custom:mushroom-light-card
    layout: vertical
    name: Laundry
  - entity: light.office_lights
    type: custom:mushroom-light-card
    layout: vertical
    name: Office
  - entity: light.patio_lights
    type: custom:mushroom-light-card
    layout: vertical
    name: Patio
conditions:
  - condition: state
    state: 'on'
show_empty: false

type or paste code here

take a look at this:

there’s a example of just what you’re asking for:

type: custom:auto-entities
show_empty: false
card:
  type: glance
  title: Lights on
filter:
  include:
    - domain: light
      state: "on" # Remember that "on" and "off" are magic in yaml, and must always be quoted
      options:
        tap_action:
          action: toggle

If you need a list of lights which are ON and have a particular label:
use auto-entities as it was suggested, but define a list in a “template” option:

filter:
  template: >-
    {{
      states.light |
      selectattr('entity_id','in',label_entities('test 1')) |
      selectattr('state','==','on') |
      map(attribute='entity_id') | list
    }}

(do not use a “label” option, some people observed lags/freezes/etc)

Note that you cannot use “template”-defined filter AND “options”, you will have to define “options” inside the template. Discussion is in dedicated thread.