I am having issues with a script that has if - then - else structure. Am new to HA, can’t figure out how to correctly program it. Example with if - then - else in the documentation is about automation, not script and I could not understand the correct ~form for the scrip. Please take a look and suggest correct structure. The script has to toggle door lock based on status of binary sensor that shows if the door is locked or not.
thanks!
togle_front_door:
alias: "toggle door"
icon: "mdi:home-lightning-bolt"
mode: single
sequence:
- choose:
# IF door is closed
- conditions:
- condition: state
entity_id: binary_sensor.front_door_is_closed
state: 'on'
sequence:
- service: script.open_front_door
# ELSE (door is opened)
default:
sequence:
- service: script.close_front_door