Light off 5 minutes after LAST doorbell press

Trying to make an automation that turns on a light module, so that it stays on for 5 minutes after the last doorbell press. What I have now works kind of. The issue is that the light will turn off 5 minutes after the first doorbell press. If someone presses the doorbell within that 5 minutes, it doesn’t extend the time. Any suggestions? Thank you.

alias: Doorbell Light 5 minutes
description: ""
triggers:
  - trigger: webhook
    allowed_methods:
      - POST
    local_only: true
    webhook_id: doorbell-zzzzzzzzzzzzzzzzz
conditions: []
actions:
  - type: turn_on
    device_id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    entity_id: yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
    domain: switch
  - delay:
      hours: 0
      minutes: 5
      seconds: 0
  - type: turn_off
    device_id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    entity_id: yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
    domain: switch
mode: single

Change the automation’s mode from single to restart.

Reference

Script Modes

1 Like

Thank you very much. I’ve only been using the graphical editor for making automations (newb), so never saw that option.

1 Like

For future reference, the Automation Editor in Visual mode, in its current form, doesn’t exposes all of Home Assistant’s automation capabilities. Some of this is by design, to insulate novice and intermediate users from too much complexity, and some by omission (i.e. no one has yet exposed certain features in the UI).