Google cast, discovery and battery powered

I have a bunch of google home devices (home, home mini, and a third party portable speaker).

I’m using discovery to find all the devices - which is great. Except the portable speaker isn’t always powered/on. And so if HA is restarted, the discovery fails to find it, and lovelace complains

No state available for media_player.portable_speaker

The device does show in the discovery integrations, although as entity unavailable.

SO - how to fix? Do I just need to give it a static IP and list it manually under media_players: ?

Guess you could manually list it with an IP address but if it’s not available it probably still will show with the same message on Lovelace.
Maybe you could create a template sensor that check’s the state of the media_player and use this to conditionally display the media_player?
Something along the lines of:

binary_sensor:
  - platform: template
    sensors:
      portable_speaker_online:
        friendly_name: "Portable Speaker Online"
        value_template: >-
          {{states("media_player.portable_speaker") != "unknown" }}

then in Lovelace, something like:

    cards:
      - type: conditional
        conditions:
          - entity: binary_sensor.portable_speaker_online
            state: "on"
        card:
          type: entities
          show_header_toggle: false
          entities:
            - entity: media_player.portable_speaker