Automation to only sound alarm siren for 20 mins

Hi , well after 8 years I finally moved all my devices to HA and turned off my old Smarthings hub. However in trying to write the automation for the alarm panel to sound the siren under certain conditions( door opened when I’m away) I can turn on the siren but I can’t find a way to tell it only to sound for 20 mins , any ideas please

Thank you Andy

A second automation triggered when the siren has been on for 20 minutes. There’s no particular benefit to be had from cramming everything into one automation.

Thanks for the reply , I did think about this but how would i tell the second automation what time to use as its trigger ?

Does this look about right


```alias: Turn off Siren after 20 Mins
description: ""
trigger:
  - platform: state
    entity_id:
      - switch.hallway_siren
    from: "off"
    to: "on"
condition: []
action:
  - type: turn_off
    device_id: 23b14f76f37806b0d014b1e7fa756e5e
    entity_id: 29daccf11c40c7ac04cf9b474d04528e
    domain: switch
  - delay:
      hours: 0
      minutes: 20
      seconds: 0
      milliseconds: 0
mode: single

nuking device_id

are you building the automation in the ui? if so,look at the “for” section in the trigger.

alias: Turn off Siren after 20 Mins
description: ""
trigger:
  - platform: state
    entity_id:
      - switch.hallway_siren
    from: "off"
    to: "on"
    for:
      minutes: 20
condition: []
action:
  - type: turn_off
    entity_id:
      - switch.hallway_siren
mode: single

That works well , thank you