Problems using script variables in if / else queries

Dear all,

Can somebody help me, please. I’m trying to query a variable in a script. No error is reported. But it never jumps into the branch. What am I doing wrong, or can’t this stuff work?

Example Code:

#**Automation** (Only the call of the service):

  action:
    - service: script.script_rollo_open_all
      data:
        title: 'Sommerautomatisierung'
        message: 'Rollo am Morgen zum Lüften geöffnet!'
        orientation: 'all'

#**Script** (I switch a Boolean as an example):

script_rollo_open_all:

  fields:
    title:
      description: 'The title of the notification'
      example: 'State change'
    message:
      description: 'The message content'
      example: 'The light is on!'
    orientation:
      description: 'geographic direction'
      example: 'all'
        
  sequence:
    # send a message
    - service: notify.telegram
      data_template:
        title: "{{ title }}"
        message: "{{ message }}"
    # Test
    - service: input_boolean.turn_on
      data_template:
        entity_id: >
          {% if ( "{{ orientation }}"  == 'all' ) %}
            input_boolean.automatisierung_schlafzimmer
          {% endif %}

this example does not work: ( “{{ orientation }}” == ‘all’ )
this example works: is_state(‘input_boolean.automatisierung_gaestezimmer’, ‘on’)

Is it even possible to query a string variable in a script with an “If”?

I hope someone can help me.

BR Markus

    - service: input_boolean.turn_on
      data_template:
        entity_id: >
          {% if orientation  == 'all'  %}
            input_boolean.automatisierung_schlafzimmer
          {% endif %}
2 Likes

Many Thanks.

I’ve tried every variation that isn’t. You made my day :slight_smile:

Regards Markus

1 Like

Then please mark the second post from @anon43302295 as “solution”, and if you want to, press the heart-button as well. :slight_smile:

Done. Thx for this note :slight_smile:

1 Like