Motion detected -> lights on. no motion within 10mins, turn lights off

I use the timer method. The PIR detects motion, turns on the light, starts the timer. As long as their is motion at the PIR, the timer gets restarted. After (in my case 2 minutes) there is no motion, the lights shuts off. Works great.
Automation file

- alias: Turn on driveway floodlight when there is movement
  trigger:
    - platform: state
      entity_id: binary_sensor.drivewaypir
      to: 'on'
  condition:
    - condition: state
      entity_id: sun.sun
      state: 'below_horizon'
  action:
    - service: homeassistant.turn_on
      entity_id: script.timed_driveway

Script file

timed_driveway:
  alias: "Turn on floodlight and set timer"
  sequence:
    # Cancel ev. old timers
    - service: script.turn_off
      data:
         entity_id: script.driveway_off
    - service: switch.turn_on
      data:
        entity_id: switch.ge_unknown_type4952_id3033_switch_13_0
    # Set new timer
    - service: script.turn_on
      data:
        entity_id: script.driveway_off

driveway_off:
  alias: "Turn off floodlight after 2 minutes"
  sequence:
    - delay:
        minutes: 2
    - service: switch.turn_off
      data:
        entity_id: switch.ge_unknown_type4952_id3033_switch_13_0
4 Likes