How to create automation to calibrate multiple curtains

Dear all

Does anybody know if is it possible to create one automation with input_select to calibrate curtains?

I have four curtains: Bedroom Window One, Bedroom Window Two, etc.

Current config

input_boolean:
  curtains_calibration:
    name: "Calibrate curtain"
    initial: off
    icon: mdi:window-open-variant

automation:
  - alias: 'Calibrate curtain'
    trigger:
      - platform: state
        entity_id: input_boolean.curtains_calibration
        to: 'on'
    action:
    - service: mqtt.publish
      data:
        topic: zigbee2mqtt/Bedroom Window Two/set
        payload: '{ "options": { "reset_limits": true } }'
    - service: cover.close_cover
      entity_id: cover.bedroom_window_two
    - delay:
        seconds: 15 #wait for closure complete
    - service: cover.open_cover
      entity_id: cover.bedroom_window_two

Should I do something like this

input_select:
  curtain_select1:
    name: Curtain Select 1
    options:
      - "Bedroom Window One"
      - "Bedroom Window Two"
  curtain_select2:
    name: Curtain Select 2
    options:
      - "bedroom_window_one"
      - "bedroom_window_two"
...
    - service: mqtt.publish
      data:
        topic: zigbee2mqtt/"{{ states('input_select.curtain_select1') }}"/set
...
    - service: cover.close_cover
      entity_id: cover."{{ states('input_select.curtain_select2') }}"

Will it work?

Or is it easy not to bother and create 4 different automations?

what about writing a script and passing entity name as parameter into that script. I have this example script with cover_id parameter and you can find an example call;

action:
  - service: script.curtain_just_light
    data:
      cover_id: cover.bedroom_curtain
alias: Curtain - with light
sequence:
  - service: cover.close_cover
    data_template:
      entity_id: '{{ cover_id }}'
  - delay:
      hours: 0
      minutes: 1
      seconds: 0
      milliseconds: 0
  - service: cover.open_cover
    data_template:
      entity_id: '{{ cover_id }}'
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - service: cover.stop_cover
    data_template:
      entity_id: '{{ cover_id }}'
mode: single

Base on your advice to create a script. I came up with this.

input_boolean:
  curtains_calibration:
    name: "Calibrate curtain"
    initial: off
    icon: mdi:window-open-variant
input_select:
  curtain_select1:
    name: Curtain Select 1
    options:
      - "Living Room Window One"
      - "Living Room Window Two"
      - "Bedroom Window Two"      

script:
  curtains_calibration:
    description: "Curtains Calibration Script"
    fields:
      cover_name:
        description: "Curtain Name"
        example: "Living Room Window One"
      cover_id:
        description: "Curtain ID"
        example: "living_room_window_one"
    sequence:
    - service: mqtt.publish
      data_template:
        topic: 'zigbee2mqtt/{{ cover_name }}/set'
        payload: '{ "options": { "reset_limits": true } }'
    - service: cover.close_cover
      data_template:
        entity_id: '{{ cover_id }}'
    - delay:
        seconds: 20
    - service: cover.open_cover
      data_template:
        entity_id: '{{ cover_id }}'
    mode: single

automation:
  - alias: 'Calibrate curtain'
    trigger:
      - platform: state
        entity_id: input_boolean.curtains_calibration
        to: 'on'
    action:
      - service: script.curtains_calibration     
        data_template:
          cover_name: '{{ states.input_select.curtain_select1.state }}'
          cover_id: >-
              {%- if states.input_select.curtain_select1.state  == 'Living Room Window One' -%}
              cover.living_room_window_one
              {%- elif states.input_select.curtain_select1.state  == 'Living Room Window Two' -%}
              cover.living_room_window_two
              {%- elif states.input_select.curtain_select1.state  == 'Bedroom Window Two' -%}
              cover.bedroom_window_two             
              {%- endif -%}
      - service: input_boolean.turn_off
        target:
          entity_id: input_boolean.curtains_calibration
1 Like