Automations reversing themselves when retriggered

I am running into an issue where if I have an automation with a delay in the action (ie: door sensor turns light on for 10 minutes, then turns it off) it just turns the light off if the automation is retriggered (ie: I close and reopen the door before the delay ends), instead of just restarting the automation.

Is there something wrong with my automation causing this, or is it something that has always happened and I just haven’t noticed :slight_smile:

Example of code in question:
` #turn on porch light based off opening front door at night

  • alias: Porch Light when opening front door
    trigger:
    platform: state
    entity_id: binary_sensor.front_door_37
    to: ‘on’
    condition:
    condition: or
    conditions:
    • condition: sun
      after: sunset
      after_offset: “-00:45:00”
    • condition: state
      entity_id: sun.sun
      state: ‘below_horizon’
    • condition: and
      conditions:
      • condition: state
        entity_id: sun.sun
        state: above_horizon
      • condition: numeric_state
        entity_id: sensor.yr_cloudiness
        above: 75
        action:
  • service: light.turn_on
    entity_id:
    • light.front_porch_light_30
  • delay: “00:10:00”
  • service: light.turn_off
    entity_id:
    • light.front_porch_light_30`

Thank you!

You should add an additional condition to make sure the light is not on as a condition, so that you do not activate multiple (and possibly conflicting) triggers.

1 Like

If you want to reset the timer when the door opens, I use the example of kitchen light motion for many timed switches like this.

2 Likes