Script, choose: Identify "unavailable" entity

Chooser condition appears not to be able to identify the “unavailable” state of an entity.

I am having difficulties with a script which turns on the TV, starts the plex app, and then plays a movie. That is, the basic script works, but when adding the chooser to skip turning on the tv and start the plex app if they are already up and running, fails.
The yaml script below works, but if I uncomment the “choose” part, it fails to start Plex (set Plex as source on the TV, and thereby make the plex media player available). I tried to include a not condition, but it then complained about a null value.

Any ideas?

play_frost:
  alias: Turn on Tv, start plex and play movie
  mode: single
  sequence:
  - choose:
    - conditions:
      - condition: state
        entity_id: media_player.stue
        state: "off"
      sequence:
      - data: {}
        entity_id: media_player.stue
        service: media_player.turn_on
      - delay: '5'
#  - choose:
#    - conditions:
#      - condition: state
#        entity_id: media_player.plex
#        state: "unavailable"
#      sequence:
#        - service: media_player.select_source
#          entity_id: media_player.stue
#          data:
#            entity_id: media_player.stue
#            source: Plex
#        - delay: '20'
  - service: media_player.select_source
    entity_id: media_player.stue
    data:
      entity_id: media_player.stue
      source: Plex
  - delay: '20'
  - service: media_player.play_media
    entity_id: media_player.plex
    data:
      entity_id: media_player.plex
      media_content_id: '{ "library_name": "Movies", "video_name": "Frozen" }'
      media_content_type: VIDEO

Not sure this is the issue you’re having, but I added a service to the upcoming 0.115 that will scan for new Plex clients. This is useful when the underlying device is turned on in an automation like yours.

This will still depend on the Plex server reporting that it “sees” the new player so it still may need delays or similar.

That might fix it. I have a gut feeling that the missing plex media_player results in a Null pointer when retrieving the entity. Considering the chooser functionality is rather new and all.

Will it be possible to search for a specific media_player and return a bool? Or does it fire an event when a new media_player is discovered?