Keep automation running

Hi All,

I am trying to do the following;
I have a zigbee door sensor, when this opens when a specific switch si turned “on” i want my buzzer (on a esphome) to start buzzing until i turn the specific switch to “off”. See it as a simple alarm setup.

I do have this working, however, with below automation, the buzzer stops buzzing as soon as i close the door. The switch for the buzzer in HA however keeps “on” but the buzzer stops.

Is there a way i can keep the buzzer going untill i turn off the switch to off (most likely with another automation saying when switch turned off, turn off buzzer)?

alias: HomeAlarm
description: ''
trigger:
  - type: opened
    platform: device
    device_id: 2e627724be9c9e49481d1220aa680393
    entity_id: binary_sensor.deursensor_achterdeur_ias_zone
    domain: binary_sensor
condition:
  - condition: state
    entity_id: input_boolean.homealarm
    state: 'on'
action:
  - service: switch.turn_on
    data: {}
    target:
      entity_id: switch.buzzer_alarm
mode: single

Just reverse the logic:

alias: HomeAlarm
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.deursensor_achterdeur_ias_zone
    to: 'off'
condition:
  - condition: state
    entity_id: input_boolean.homealarm
    state: 'on'
action:
  - service: switch.turn_off
    data: {}
    target:
      entity_id: switch.buzzer_alarm
mode: single