Glance card show entity based on condition?

I’m attempting to setup a glance card that will show entities when certain conditions exist since it doesnt make sense to have it showing when it’s docked for the other 165 hours a week it’s not cleaning.

For example, I want the status and last cleaning end time entities to always show, but the battery level only when it’s under 100% and the progress meter when it’s above 0%. I’ve found where I can do similar with a conditional card, but that seems to be the whole card and I’d like to do it with just the entities. Is there a way to do this with Glance, or a different type of card I’m just not aware of?

Thanks!

Entity-filter card can handle this for you.

type: entity-filter
entities:
  - entity: sensor.last_cleaning
  - entity: sensor.status
  - entity: sensor.battery
    state_filter:
      - operator: "<"
        value: 100
card:
  type: glance
  columns: 3

Your code is giving me an error when I transposed it with my entity names. I have the below:

entities:
  - entity: vacuum.s8_maxv_ultra
  - entity: sensor.s8_maxv_ultra_last_clean_end
  - entity: sensor.s8_maxv_ultra_cleaning_progress
  - entity: sensor.s8_maxv_ultra_battery
    state_filter:
      - operator: "<"
        value: 100
card:
  type: glance

That is giving me a incorrect filter config. Took a look through the linked documentation (Thank you!) and that doesnt seem to help. I rearranged the entity order so that the persistent entities are the top two, but the other two I want to show up only when the number is <100 and the above isnt letting it happen. New to yaml; my dayjob is in powershell so sorry for the neediness :frowning:

What is the error, can you be more specific?

Incorrect filter config;sorry. Legit all it says. If I put yours in verbatim, it gives me the same. It definitely appears to follow syntax based on the link you provided but it definitely doesn’t like something with the filter it appears. I have the below half working but it’s applying the filter to every entity instead of targeting a specific entity. Is it possible to apply the state filter to a specific entity?

entities:
  - vacuum.s8_maxv_ultra
  - sensor.s8_maxv_ultra_last_clean_end
  - sensor.s8_maxv_ultra_cleaning_progress
  - sensor.s8_maxv_ultra_battery
state_filter:
  - operator: "<"
    value: 100
  - operator: "in"
    value: "docked, cleaning"
card:
  type: glance

This is giving me the below. Problem being that it hides the battery (because the battery is charged) but there’s no reason to show cleaning progress unless the cleaning is in progress (above 0). Being able to target each entity would fix this.

Ahh I’m sorry I missed one line. Try this:

type: entity-filter
entities:
  - entity: vacuum.s8_maxv_ultra
  - entity: sensor.s8_maxv_ultra_last_clean_end
  - entity: sensor.s8_maxv_ultra_cleaning_progress
  - entity: sensor.s8_maxv_ultra_battery
    state_filter:
      - operator: "<"
        value: 100
state_filter: []
card:
  type: glance

You can apply unique filters to each entity, but the card also expects a list of global state filters or conditions as well, which you can just define as an empty list. Missed that part.

Hmm actually maybe that’s not quite right. I’m sure it’s close but I think I’m missing something, but ran out of time to check right now.

Thanks for the help! Home Assistant via ChatGPT isnt giving me much to work off either. It actually thinks it cannot be done with the entity-filter…

You’re right—state_filter only supports string matches directly, and doesn’t support numeric comparisons like <10. To apply more complex logic like numeric comparison, we need to use a template condition instead.

Unfortunately, the entity-filter card does not support full templating like Jinja2. However, we can use the newer conditional card as a workaround when we need more advanced display logic.

Here’s how you can achieve the desired behavior using a combination of conditional cards inside a horizontal-stack (to mimic a glance card)

This is entirely wrong.

https://www.home-assistant.io/dashboards/entity-filter/#operator-filter

Ok I think I figured out what this needs now.

Entity-filter requires one global filter, either state-filter or conditions. State-filter is the legacy but I’ll use that as that’s what I’m familiar with.

In additon to that, you can set state-filter on any individual entity and that will replace the global defined state-filter.

So if you have some entities you want to always show, just make a dummy global state filter, I chose state != "".

Then on individual entities, you can define whatever custom filtering logic you want. Here’s a full example.

type: entity-filter
entities:
  - sensor.sun_next_dawn
  - entity: sensor.carbon_monoxide
    state_filter: 
      - operator: "<"
        value: 100
  - entity: sensor.carbon_dioxide
    state_filter:
      - operator: ">"
        value: 100
state_filter:
  - operator: "!="
    value: ""
card:
  type: glance

Sorry this card is more confusing than I realized :grin:

I’ll never complain about free help. This is perfect. My working code below in case anyone else has a similar question!


entities:
  - entity: vacuum.s8_maxv_ultra
    name: Vacuum
  - entity: sensor.s8_maxv_ultra_battery
    name: Battery
    state_filter:
      - operator: <
        value: 100
  - entity: sensor.s8_maxv_ultra_last_clean_end
    name: Last Run
  - entity: sensor.s8_maxv_ultra_cleaning_progress
    name: Progress
    state_filter:
      - operator: ">"
        value: 0
state_filter:
  - operator: "!="
    value: "null"
state_color: true
card:
  type: glance
  title: Vacuum

Produces the below when it’s charged and not running.