Passing variables from automation to cover

Hi,

I’m trying to make an automation for 4 different screens, using only 1 “general” cover, script and sensor template.
The screens are called: kitchen, living room, bedroom1 and bedroom2.
The screens must be able to be operated independently of each other.

Before I run the cover template, my intention is to add a variable in the automation that controls the corresponding screen.
Something like {% set window = ‘kitchen’ %} before calling the “cover.close_cover” service, but that doesn’t work.
It seems that the variable is not taken over by the cover template.

Who can help me to solve this problem.
Thank you.

cover:
  - platform: template
    covers:
      cover_group:
        device_class: shade
        friendly_name: "Cover Group"
        value_template: '{{ is_state("sensor.cover_group", "open") }}'

        open_cover:
          service: script.cover_group
          data:
            modus: "open"
            window: '{{ window }}'

        close_cover:
          service: script.cover_group
          data:
            modus: "close"
            window: '{{ window }}'

        stop_cover:
          service: script.cover_group
          data:
            modus: "stop"
            window: '{{ window }}'

        set_cover_position:
          service: script.cover_group_position
          data:
            position: '{{ position }}'
            window: '{{ window }}'

        icon_template: >-
          {% if is_state("sensor.cover_group", "open") %}
            mdi:window-open
          {% else %}
            mdi:window-closed
          {% endif %}


script:
  cover_group:
    sequence:
      - service: 'cover.{{ modus }}_cover'
        target:
          entity_id: 'screen.{{ window }}'

  cover_group_position:
    sequence:
      - service: cover.set_cover_position
        target:
          entity_id: 'screen.{{ window }}'
        data:
          position: '{{ position }}'


sensor:
  - platform: template
    sensors:
      cover_group:
        value_template: >-
          {% if is_state("screen.{{ window }}", "open") %}
            open
          {% else %}
            closed
          {% endif %}


automation:
    trigger:
      - platform: sun
        event: sunset
        offset: "+00:30:00"
    action:
      - service: cover.close_cover
        target:
          entity_id: cover.cover_group
        {% set window = 'kitchen' %}

You cant pass variables to integration configurations.

Pass the variable to a script that opens the required cover(s).

https://www.home-assistant.io/integrations/script/#passing-variables-to-scripts

Thank you very much for the answer.
So, if I understand correctly, each screen has its “own” cover? In my case, 4 screens → 4 covers?

Correct.

Apologies for raising the dead here, tom, but this was the most relevant post to my query.

You say here that you can’t pass variables (which I’m not arguing against), but the code that complex1 has put in their original post was taken from the documentation - Template Cover - Home Assistant. (I came to this post in my search for what this “modus” was).

Does this mean that these code examples in the documentation are incorrect?

Can you take a screenshot of where this appears in the documentation?

I don’t see it.

The only data options you can specify in the cover service calls (other than the entity) are: position and tilt_position see:

https://www.home-assistant.io/integrations/cover/#services