Template syntax for entity_id in intent_script

How to combine the entity_id value into intent_script correctly? I need to use one of the values: {name} or {media_player}, which the system will send, depending on the sentence said

intent_script:
  SetVolume:
    action:
      service: "media_player.volume_set"
      data:
        entity_id: "{{ name }}" or "{{ media_player }}"    #???
        volume_level: "{{ volume / 100.0 }}"
    speech:
      text: "Volume changed to {{ volume }}"

And I’m also interested in whether HassLightSet, HassTurnOff, HassTurnOn exist in YAML format? It would be useful to use them as examples.

Name of the media_player? If yes you have to use more than 1 action because if your intent passes wrong info, then you’ll have errors in HA.

    action:
    - variables:
        media_player: >
          {{ states.media_player | selectattr('name', 'eq', name) | map(attriubte='entity_id') | list | first | default }}
    - condition: template
      value_template: "{{ media_player is not none }}"
    - service: "media_player.volume_set"
      data:
        entity_id: "{{ media_player }}"
        volume_level: "{{ volume / 100.0 }}"

If you can control the intents themselves, just this should work


    action:
      service: "media_player.volume_set"
      data:
        entity_id: >
          {{ states.media_player | selectattr('name', 'eq', name) | map(attriubte='entity_id') | list | first | default }}
        volume_level: "{{ volume / 100.0 }}"

Сonfusing naming is used here. But both values pass media_player entities.
for {name}, the search occurs in aliases and names.
for {media_player } is selected from a specific list

if a foreign language does not bother, I attach sentences

language: "ru"
intents:
  SetVolume:
    data:
      - sentences:
          - "[установить|изменить|сделать] громкость {name} [на] {volume} [процентов]"
        requires_context:
          domain: "media_player"
      - sentences:
          - "[установить|изменить|сделать] громкость [в] {media_player} [на] {volume} [процентов]"
lists:
  media_player:
    values:
      - in: "(спальне)"
        out: "media_player.soundbedroom"
      - in: "(зале)"
        out: "media_player.soundzal"
  volume:
    range:
      from: 0
      to: 100

The option with two scripts works, but I wanted to optimize it

let’s abstract from concrete entities.
Suppose a script can get one of two variables with a numeric value (depending on the phrase said). Is it possible to make a universal record for this case?
{{ var1 }} or {{ var2 }}