No State Available in Lovelace

Is there a way to hide media players when they are not available in Lovelace? I am getting this error on my plex media players. When I restart Home Assistant, the media players for plex do not show up until I start streaming something to them. I understand why the card is not showing up (there is no entity called “media_player.plex_media_room” yet), but is there a way to hide it until the media player becomes available?

changes to this once something has been streamed to it

Use entity-filter wrapper on top. See https://github.com/home-assistant/ui-schema/issues/82

Thank you! I think it might work, but I am having some trouble. How should the “card” portion of the filter be set up? When I use the code below, it filters correctly, but it shows a condensed version of the media player.

        entities:
          - media_player.roku_2
        state_filter:
          - 'unavailable'
          - 'playing'
          - 'paused'
          - 'idle'
        card:
          - type: media-control
            entity: media_player.roku_2

image

When I set it up like the following, The regular media player card shows up, but the filter does not work. On version 74.0 if that makes a difference

      - type: entity-filter
        entities:
          - media_player.roku_2
        state_filter:
          - 'unavailable'
          - 'playing'
          - 'paused'
          - 'idle'
        card:
          type: media-control
          entity: media_player.roku_2

I’ve added your config as an example to the Lovelace gallery and it shows the correct card. https://home-assistant-lovelace-gallery.netlify.com//#demo-hui-entity-filter-card

Thank you for the example. I have adjusted my code to match:

      - type: entity-filter
        entities:
          - media_player.roku_2
        state_filter:
          - 'playing'
        card:
          type: media-control
          entity: media_player.roku_2

After playing around with it for a bit. I am still having an issue with the state filter specifically for “media-control” cards. When I remove type: media-control it works as expected.

View when idle:
image

View when playing:
image

When I change to type: glance It still works as expected

View when idle:
image

View when playing:
image

Now when I change type: media-control I get the following view when idle even though I would expect it to be blank like the prior two idle views from above.
image

Is there something I am missing?

Did you find a solution for this? I’m having the exact same problem.

No. I haven’t found a solution yet.

A solution for this is a new card coming in 0.75 (conditional). You could try in the current setup to add ‘show_empty: false’ as that might solve your problem.

have you test your solution? do you mind sharing your config/code on github? i am experiencing the same thing on .78

  - type: conditional
    conditions:
    - entity: media_player.your_player
      state_not: "unavailable"
    card:
      type: media-control
      entity: media_player.your_player
5 Likes

Thanks, that fixed the problem!

Sorry, which .YAML file would i need to input this code?

It’s Lovelance config

ui-lovelace.yaml

1 Like

Did some research on the LoveLave UI (still abit of a noob). Worked out how to configure the UI through YAML and your fix works!

Your a Star!!!

Thanks for publishing a solution. I had the same problem with my Chromecast being powered by a TV and when the TV is off - the Chromecast is also unavailable.

However I think this is rather a workaround. In my opinion Lovelace should work as the good, old pre-0.86 UI and show a media player card with status ‘unavailable’. I’ll file a bug about this in Github

Thank you, worked like a charm!

I had the same problem. Disabled discovery for PLEX component and aaddedd: remove_unavailable_clients: true to its configuration solved problem.

media_player:
  - platform: plex
    remove_unavailable_clients: true