Template in script

Dear community,

I need your help.
I want to control in a script, depending on switches and input parameters, which blinds are moved to a certain position.

Unfortunately no roller blind moves. In my example I have two roller blinds.
If I remove one of the services, it works.
Why? Is it only possible to define one service in a sequence using one template?

Listed below, my example:

script_rollo_test:
  alias: Setzt definierte Rollos Test
  icon: "mdi:script-text-outline"
  description: 'Setzt definierte Rollos Test'

  fields:
    title:
      description: 'The title of the notification'
      example: 'State change'
    message:
      description: 'The message content'
      example: 'The light is on!'
    position:
      description: 'New position of cover'
      example: 30
    orientation:
      description: 'geographic direction'
      example: 'all'

  sequence:
    # Benachrichtigung zur Kontrolle
    - service: notify.telegram
      data_template:
        title: "{{ title }}"
        message: "{{ message }} {{ orientation }} {{ position }}"
    # Rollo Osten Gästezimmer auf bestimmte Position stellen
    - service: cover.set_cover_position
      data_template:
        entity_id: >
          {% if is_state('input_boolean.automatisierung_gaestezimmer', 'on') 
            and
              (orientation == 'all'
              or
                orientation == 'east'
              or
                orientation == 'gast') %}
            cover.rollo_gaestezimmer
          {% endif %}
        position: "{{ position }}"
    # Rollo Gästezimmer auf bestimmte Position stellen
    - service: cover.set_cover_position
      data_template:
        entity_id: >
          {% if is_state('input_boolean.automatisierung_schlafzimmer', 'on') 
            and
              (orientation == 'all'
              or
                orientation == 'east'
              or
                orientation == 'schlafz') %}
            cover.rollo_schlafzimmer
          {% endif %}
        position: "{{ position }}"

I hope that someone can help me. I’m a little desperate right now.

BR Markus

You don’t have {% else %} statements. So if the ‘if conditions’ are not met the script generates an error and stops.

1 Like

Thx for your response Tom,

Can i add an else statement without entity-id?

The else should do nothing, is this possible?

Regards Markus

No, but you can use a non-existent entity_id, such as cover.none. Calling a service for a non-existent entity_id effectively does nothing.

1 Like

Thx pnbruckner,

this is a good idea.

regards Markus