Show entities conditionally, only show if they exist?

using this:

  - type: entities
    title: Air quality
    show_header_toggle: false
    entities:
      - sensor.luftdaten_28692_p1
      - sensor.luftdaten_28692_p2
      - sensor.luftdaten_20751_p1
      - sensor.luftdaten_20751_p2
      - sensor.u_s_air_pollution_level
      - sensor.u_s_air_quality_index
      - sensor.u_s_main_pollutant

often causes this:

14

because the integration isn’t fully initiated for individual sensors, for what ever reason maybe. I don’t think I can use the condition card to prevent this, but would there be another way to have the card only show entities that in fact exist?

its not that these yellow entities have an empty value, they simply aren’t available in the states.

thanks for having a look

Hi,
This is what i have done for Plex in my lovelace:

      - entity: media_player.tvdatorn
        type: conditional
        conditions:
          - entity: media_player.tvdatorn
            state_not: "unavailable"
        card:
          type: media-control
          entity: media_player.tvdatorn

Hopefully you can re-use this :slight_smile:

1 Like

not sure there, Ive looked at that, but aren’t the condition valdi for the whole card below? Would this require a card per entity as a consequence?
Ive also looked at the monster card, but couldn’t find a way to formulate a per entity condition of existence, or not being 'unavailable' or even ''

regular HA simply doesn’t show the entities in a group when they don’t exist, that’s sorely missed right now, with several of the integrations not creating there entities as they should.

Just a thought.
Maybe use the auto-entities card?
Name your sensor like sensor.air_quality_xxx and filter with

filter:
  include:
    - entity_id: "sensor.air_quality_*"
2 Likes

Not sure, have not tested that. Perhaps it is not usable as you say :frowning:
I wrote to fast without thinking about that, sorry

easy with a monster card

  - card:
    type: 'custom:monster-card'
      show_header_toggle: false
      title: Kiras Zimmer
      type: entities
    filter:
      exclude:
        - state: unavailable
      include:
        - entity_id: switch.luftbefeuchter_kira_switch
        - entity_id: switch.lichterkette
        - entity_id: light.kiras_deckenlampe

o that would be nice! Ive tried this:

  - type: 'custom:monster-card'
    show_empty: false
    show_header_toggle: false
    card:
      type: entities
      title: Air quality
    filter:
      exclude:
        - state: unavailable
      include:
        - sensor.luftdaten_28692_p1
        - sensor.luftdaten_28692_p2
        - sensor.luftdaten_20751_p1
        - sensor.luftdaten_20751_p2
        - sensor.u_s_air_pollution_level
        - sensor.u_s_air_quality_index
        - sensor.u_s_main_pollutant

but it gives me all entities not unavailable…and they are a many :wink:

1 Like

ok thanks, will try that later on, seems a bit more work understanding the card to just quickly add it.
looks good.

hm I dont get it. It should only show the entities added on “include” and exclude all that are unavailable.

The problem is that if an entity does not exist, it has no state ‘unavailable’.
It’s still not there.

ok, I dont know there is a different between “unavailable” and “not available”.

@Mariusthvdb

try to add - entity_id: in front of your entities. Look at my example. The Monster Card also did not show “not available” entity. Works great for me

  - type: 'custom:monster-card'
    show_empty: false
    show_header_toggle: false
    card:
      type: entities
      title: Air quality
    filter:
      exclude:
        - state: unavailable
      include:
        - entity_id: sensor.luftdaten_28692_p1
        - entity_id: sensor.luftdaten_28692_p2

exactly, so we should template the ‘if available’ for these entities… now how to do that?

Thing is this is so basic, it seems almost a bug for Lovelace not to be able to catch this, and force us to use al kinds of templates/custom cards.

1 Like

yes! that was it!

using:

  - type: 'custom:monster-card'
    show_empty: false
    card:
      type: entities
      title: Air quality
      show_header_toggle: false
    filter:
      exclude:
        - state: unavailable
      include:
        - entity_id: sensor.luftdaten_28692_p1
        - entity_id: sensor.luftdaten_28692_p2
        - entity_id: sensor.luftdaten_20751_p1
        - entity_id: sensor.luftdaten_20751_p2
        - entity_id: sensor.u_s_air_pollution_level
        - entity_id: sensor.u_s_air_quality_index
        - entity_id: sensor.u_s_main_pollutant

(note I had the show_header_toggle: false in the wrong place originally also)

gives the desired result:
57

thanks!

1 Like

tried this:

  - type: custom:auto-entities
    card:
      type: entities
      title: Air quality auto
    filter:
      include:
        - entity_id: "*u_s_air_*"
        - entity_id: "*luftdaten*"

but it errors out:

01
because of:

09

apparently it doesn’t check first if the entity exists, like the original monster card does?

update

forget about the above, I made a stupid error, and saved the resource on the wrong instance…

it works fine!
54

using:

  - type: custom:auto-entities
    card:
      type: entities
      title: Air quality auto
      show_header_toggle: false
    filter:
      include:
        - entity_id: '*.u_s_*'
        - entity_id: '*.luftdaten*'

so thanks, and a second solution ticked

3 Likes

Same issue here. Unfortunately I wasn’t able to solve it as described here.

This is the code I’m currently using:

title: Home
views:
  - badges: []
    cards:
      - entities:
          - entity: light.terrasse_lounge
          - entity: light.terrasse_esstisch
          - entity: light.terrasse_pool
          - entity: light.terrasse_grill
          - entity: light.terrasse_wohnzimmer
          - entity: light.terrasse_gaestezimmer
        title: Terrassenlampen
        type: entities
      - entities:
          - entity: light.flur_1
          - entity: light.flur_2
          - entity: light.flur_3
          - entity: binary_sensor.flur_1_nightlight
          - entity: binary_sensor.flur_2_nightlight
          - entity: binary_sensor.flur_3_nightlight
        title: Flurlampen
        type: entities
      - entities:
          - entity: light.stehlampe
          - entity: light.wohnzimmerlampe
          - entity: light.wohnzimmerlampe_ambilight
          - entity: binary_sensor.wohnzimmerlampe_nightlight
        title: Wohnzimmerlampen
        type: entities
      - entities:
          - entity: light.leuchtstreifen
          - entity: light.esstischlampe
          - entity: light.esstischlampe_ambilight
          - entity: binary_sensor.esstischlampe_nightlight
        show_header_toggle: true
        title: Küche
        type: entities
    icon: 'mdi:lightbulb-on-outline'
    panel: false
    path: lampen
    title: ''

As you can see in the picture, I use for some lamps the old power wall switch so they are partially not existent.

Any hints how to hide them in case they are currently not available?

have you tried the custom auto-entities card? your example uses the regular entities card.

You are right!
I posted the code without the monster card part :-/
Monster card was not working for me but custom:auto-entities did it :slight_smile:
Thanks!

Is there a way to use conditions and state to hide and show entire horizontal/vertical stacks in Lovelace? Mine isn’t unavailable, but wanted to hide and show a remote based on state of my harmony. Right now I am doing it, but creating a card for each button and hiding each one with state. Glad to share my code but it’s a lot.

Took me a while to figure this out.

If you want to use an Entities card, you need to add both type: conditional and include both conditions and row.

However there’s a bug in the header toggle that means it won’t toggle conditional rows: https://github.com/home-assistant/frontend/issues/4865

entities:
  - entity: switch.switch1
  - entity: switch.switch2
  - type: conditional
    conditions:
      - entity: switch.switch3
        state: 'on'
    row:
      entity: switch.switch3
title: Hallway
type: entities
1 Like

Screenshot_2020-11-11 Home Assistant
I’m trying to hide “Flame Out” under certain conditions in a multiple entity row but failed thus far. First of all, is it doable? If so, what am I missing in the following configuration? Tried out various indentations but no luck.

type: entities
entities:
  - entity: sensor.str_dt_in_out
  - entities:
    type: conditional
    conditions:
      - entity: sensor.last_flame_out
        state_not: Flame On
      - entity: switch.floor_pump_208
        state_not: 'on'
    row:
      entity: sensor.last_flame_out2
      - entity: sensor.floor_pump_power
        name: Power
        unit: W
    entity: switch.floor_pump_208
    icon: 'mdi:lightbulb'
    state_color: true
    toggle: false
    type: 'custom:multiple-entity-row'
show_header_toggle: false