Need 'guard' for my non existing entity (media_player) in template

so I get:

Intercom message: Error executing script. Invalid data for call_service at pos 6: not a valid value for dictionary value @ data['entity_id']

using this script:

  intercom_message:
    alias: Intercom message
    mode: restart
    sequence:
      - condition: state
        entity_id: input_boolean.announce_intercom
        state: 'on'
#      - condition: template
#        value_template: >
#          {{is_state('input_boolean.announce_intercom','on')}}
      - service: script.radio_paused_for_message
      - service: script.wakeup_radio_paused_for_message
      - service: script.spotify_paused_for_message
      - service: media_player.volume_set
        data_template:
          entity_id: >
            {{states('sensor.intercom')}}
          volume_level: >
            {{ states('input_number.intercom_volume')|float }}
#            # {{ states('sensor.intercom_volume')|float  }}
      - service: tts.google_say
        data_template:
          language: >
            {{states('input_select.intercom_language')|lower}}
          entity_id:
            - >
              {{states('sensor.intercom')}}
            - >    # this is the culprit 
              {% if states('media_player.theboss') != 'unavailable' %} media_player.theboss
              {% else %} ''
              {% endif %}
          message: >
            {% set language = states('input_select.intercom_language') %}
            {% if language == 'En' %} {{message_en}}
            {% elif language == 'Nl' %} {{message_nl}}
            {% else %} {{message_en}}
            {% endif %}
      - service: script.resume_radio_paused_for_message
      - service: script.resume_wakeup_radio_paused_for_message

thing is, the ‘media_player.theboss’ is a browser_mod entity, and only available on an active browser being touched. So, if this script is invoked on a sleeping iPhone, the error is logged. Which of course happens quite often …

had it without the if then construction first:

            - media_player.theboss

but that obviously was not much better. How to prevent an entity to be tried if the media_player is ‘unavailable’? Could I add none?

          entity_id:
            - >
              {% if states(states('sensor.intercom')) != 'unavailable'%} {{states('sensor.intercom')}}
              {% else %} none
              {% endif %}
            - >
              {% if states('media_player.theboss') != 'unavailable' %} media_player.theboss
              {% else %} none
              {% endif %}