How integrate "if then else" in script

Beginnersquestion…

I have rest command

rest_command:
  rolluik_salon_op_kort:
    url: http://192.168.1.3:80/postEvent.html?action=input&STM=0&MOD=5&CHA=0&EVT=3
  rolluik_salon_op_lang:
    url: http://192.168.1.3:80/postEvent.html?action=input&STM=0&MOD=5&CHA=1&EVT=3

and a toggle input_boolean.toggle_lang_drukken

How do I have to write the script (else part : if input_boolean.toggle_lang_drukken is on then rest_command.rolluik_salon_op_lang) ?

alias: rolluik_salon_op_kort
sequence:rest_command.rolluik_salon_op_kort
  - service: 
  - condition: state
    entity_id: input_boolean.toggle_lang_drukken
    state: 'off'
mode: single

https://www.home-assistant.io/docs/scripts#choose-a-group-of-actions

alias: rolluik_salon_op_kort
sequence: 
  - choose:
      - conditions:
          - condition: state
            entity_id: input_boolean.toggle_lang_drukken
            state: 'off'
        sequence:
          - service: rest_command.rolluik_salon_op_kort
    default:
      - service: rest_command.rolluik_salon_op_lang
mode: single

Thanks, super !

Also

alias: rolluik_salon_op_kort
sequence: 
  - service: rest_command.rolluik_salon_op_{{ 'lang' if states('input_boolean.toggle_lang_drukken') = 'on' else 'kort' }}
mode: single
1 Like

Nice…learning a lot !