Undefined variable with default value?

I created a script with a variable provided with a default value.
What should happen when I call this script without populating the variable?

I got this error:

Template variable warning: ‘override’ is undefined when rendering ‘{{ override }}’

Shouldn’t be the default value prevent this?

This is the script:

nuki_unlock_door_on_disarm:
  mode: restart
  fields:
    override:
      description: "Temporary override"
      example: false
      default: false
  sequence:
    - if:
        - condition: state
          entity_id: input_boolean.alarm_system_nuki_skip_unlock_on_disarm
          state: 'off'
      then:
        - service: script.turn_on
          entity_id: script.nuki_please_unlock
          data:
            variables:
              override: "{{ override }}"
      else:
        - service: input_boolean.turn_off
          data:
            entity_id: input_boolean.alarm_system_nuki_skip_unlock_on_disarm

Any way to get this so robust that override is never undefined?

            variables:
              override: "{{ override | default(false) }}"
1 Like