Entity filter card
The entity filter card shows only the entities from a list that match a filter, like the lights that are on. It wraps another card, the entities card by default.
The entity filter card takes a list of entities, and only shows the ones that match its filter. When the state changes, the list changes with it. Use it for questions with a changing answer: which lights are on, which doors are open, which rooms run dry.
It does not show anything itself. It hands the matching entities to another card, an entities card unless you pick another one, like a glance card. Anything you put in card goes to that card, like a title.
To show or hide a whole card based on a state, use the conditional card, or the visibility options of the card itself in the sections view.
Each entity in the list is checked against conditions, and shows when all of them are met. The conditions are the same as the visibility conditions of cards, without the entity: the card fills it in for each entity. A state condition checks the state, a numeric_state condition checks a number with above and below.
An entity can have its own conditions, which replace those of the card for that entity.
The older state_filter option still works: a list of states, or of mappings with an operator, a value, and an optional attribute. An entity shows when it matches any of them. A card can't have both conditions and state_filter.
When no entity matches, the card shows the wrapped card without rows. Set show_empty: false to hide the card instead. That is often what you want: a "Lights on" card with nothing in it adds noise.
- Give the wrapped card a title that says what the filter means, like "Open windows". Without one, people see a list and have to guess why these entities are in it.
- List every entity that could match. The card only filters; it does not find entities for you.
entities(list, required): the entities to filter. Each is an entity ID, or a mapping with anentity, its ownconditionsorstate_filter, and the options of the wrapped card for that entity, likename.conditions(list): the conditions an entity must meet to show. Required, unless you usestate_filter.state_filter(list): the older way to filter, on state or attribute values.card(mapping): the card that shows the matching entities. Defaults to an entities card.show_empty(boolean): shows the card when no entity matches. Defaults totrue.
type: entity-filter
show_empty: false
entities:
- light.living_room_lamp
- light.hallway
- light.kitchen_ceiling
conditions:
- condition: state
state: "on"
card:
title: "Lights on"The card lives in src/panels/lovelace/cards/hui-entity-filter-card.ts, and the element is <hui-entity-filter-card>. It renders a <hui-card> with the wrapped card, and gives it a new entities list whenever the matching entities change. Conditions are checked with checkConditionsMet, and the older state filters with evaluateStateFilter in src/panels/lovelace/common/evaluate-filter.ts.
When the card hides itself because nothing matches, it fires card-visibility-changed, so the section can close the gap.