Virtual Button press and release

Hi everyone,

I’ve added a siren to my HA for intrusion and fire events. Electrical wiring is correct and I’m able to enable the siren through switches in ESPHome.

I want to be able to sound (on press) and mute (on release) the sirens on-demand through a virtual push button. I’ve tried using a button but the Button Component only supports the on_press automation. Is there any way to accomplish this? This is my config.:

switch:
  - platform: gpio
    pin: D1
    name: "Burglar Siren"
    id: burglar_siren
  - platform: gpio
    pin: D2
    name: "Fire Siren"
    id: fire_siren

button:
  - platform: template
    name: "Burglar"
    id: burglar_btn
    on_press:
      then:
        switch.turn_on: burglar_siren

  - platform: template
    name: "Sirena Fuego"
    id: fire_btn
    on_press:
      then:
        switch.turn_on: fire_siren

Thanks!