Variables passing from tap_actions into a script works mostly but not within condition

I fire a tap_action like this:

tap_action:
  action: call-service
  service: script.virt_ar_speisekammer
  service_data:
    select: select.e2m_virt_ar_speisekammer_action
    what: AO
    which: cover.ar_speisekammer

with a shortened script like this to explain the misery (see line with the comment):

alias: virt_ar_speisekammer
sequence:
  - service: select.select_option
    data:
      option: "{{ what }}"
    target:
      entity_id: "{{ select }}"
  - if:
      - condition: state
        entity_id: cover.ar_speisekammer # <== wanted this to be {{ which }} aswell
        state: opening
    then:
      - service: cover.stop_cover
        data: {}
        target:
          entity_id: "{{ which }}"
mode: single
icon: mdi:transfer-up

the whole lot is somewhat longer, means the misery happens a dozend times in the complete script. I nailed it done to … works like a charm as long as one doesn’t want to pass the {{which}} which holds a cover entity_id within the condition section. And I have no idea about why it works for example in the service target section as wanted.
Help appreciated, TIA

To replace with a template condition


- condition: template
  value_template: " {{ is_state(which,'opening') }} "

Change the State Condition (which doesn’t support templating entity_id):

  - if:
      - condition: state
        entity_id: cover.ar_speisekammer # <== wanted this to be {{ which }} aswell
        state: opening
    then:

to a Template Condition:

  - if:
      - condition: template 
        value_template: "{{ is_state(which, 'opening') }}"
    then:

or to a Template Condition in shorthand notation:

  - if: "{{ is_state(which, 'opening') }}"
    then:

EDIT

Ninja’d by Olivier1974

For once :slight_smile: