Motion triggered front porch light with auto-off - Help

I wrote two automations that would turn on my porch light whenever my Ring detected motion or my front door opened at night, then turn off 1 minute after the door was closed and motion had stopped being detected. It seems to be working for the turn-on automation, but I frequently find the light still on. Anyone able to help me troubleshoot this?

  - alias: Entryway Auto On
    initial_state: true
    trigger:
      - platform: state
        entity_id: binary_sensor.ring_front_door_motion
        to: 'on'
        from: 'off'
      - platform: state
        entity_id: binary_sensor.front_door_opened
        to: 'on'
        from: 'off'
    condition:
      condition: state
      entity_id: sun.sun
      state: below_horizon
    action:
      - service: light.turn_on
        entity_id: light.entryway
  - alias: Entryway Auto Off
    initial_state: true
    trigger:
      - platform: time
        minutes: '/1'
        seconds: 00        
    condition:
      - condition: and
        conditions:
          - condition: state
            entity_id: binary_sensor.front_door_opened
            state: 'off'
          - condition: state
            entity_id: binary_sensor.ring_front_door_motion
            state: 'off'
    action:
      - service: light.turn_off
        entity_id: light.entryway

First thing first. Please click on the '</>' button to make your automation more readable.
Second you can not do what you want in one automation, you need to separate the turn on and the turn off event. You can use the for part in the state trigger:

good luck
tom

1 Like

Second thing; Share Your Projects is for finished, working projects that you are sharing with the group while explaining how you did it. I moved your post to Configuration, which is the proper category for posts with questions.

Sorry for the wrong category and for the improperly formatted code. Now… who can help with my actual question?

1 Like

I take it when you find the light is on, you have checked that the two sensors are showing as ‘off’? The code looks sound enough, so every minute it should be checking that they’re both off and then switching the light off, so the only reason it would (should) not work is if every time it checks one of the sensors is ‘on’.

1 Like