Automation Motion Light issues

I have recently made a few automations for lights that I’m having issues with. Turns light on just fine, but seems to casue a resource runaway if you will. Memory usage explodes until HA runs out of memory. I assume I’m making a simple mistake. Any input is appreciated.

Principle of automation:

On motion turn on light
wait for a time
if no motion turn off ligh
else wait for time
repeat till light is off

I used the gui to make the automation, but here’s the yaml:

alias: Utility Room Motion Light
description: Turn on Office Recessed Lights on Motion Detected
trigger:
  - type: motion
    platform: device
    device_id: 6f82f44254ee8c652e4f3b2556f53da8
    entity_id: binary_sensor.utility_room_motion_sensor_iaszone
    domain: binary_sensor
condition: []
action:
  - type: turn_on
    device_id: 5c263dd4e69e8a44b9eadb31a79d345e
    entity_id: light.utility_room_light
    domain: light
  - delay:
      hours: 0
      minutes: 0
      seconds: 30
      milliseconds: 0
  - if:
      - type: is_no_motion
        condition: device
        device_id: 6f82f44254ee8c652e4f3b2556f53da8
        entity_id: binary_sensor.utility_room_motion_sensor_iaszone
        domain: binary_sensor
    then:
      - type: turn_off
        device_id: 5c263dd4e69e8a44b9eadb31a79d345e
        entity_id: light.utility_room_light
        domain: light
    else:
      - delay:
          hours: 0
          minutes: 5
          seconds: 0
          milliseconds: 0
      - repeat:
          until:
            - condition: device
              type: is_off
              device_id: 5c263dd4e69e8a44b9eadb31a79d345e
              entity_id: light.utility_room_light
              domain: light
          sequence: []
mode: single