Timed automation stopped working

I have this simple automation where lights are turned on after sundown based on one of two motion sensors firing and turned off after 15 minutes. It used to work fine but lately the lights turn on but not off. Can someone see what in the automation might be the reason?

description: ""
triggers:
  - type: occupied
    device_id: e3077ce7c4f08c86300e363e31edac3f
    entity_id: d07e437a7526fe4c06a9dc090deccc9c
    domain: binary_sensor
    trigger: device
    for:
      hours: 0
      minutes: 0
      seconds: 1
  - type: occupied
    device_id: cc71456d3dd69dd86e60dc67ba8351d7
    entity_id: 43bae9758b459ca65b8d290f45fdd644
    domain: binary_sensor
    trigger: device
    for:
      hours: 0
      minutes: 0
      seconds: 1
conditions:
  - condition: state
    entity_id: sun.sun
    state: below_horizon
actions:
  - target:
      entity_id:
        - switch.study_lights
    data: {}
    action: switch.turn_on
  - delay:
      hours: 0
      minutes: 15
      seconds: 0
      milliseconds: 0
  - data: {}
    target:
      entity_id:
        - switch.study_lights
    action: switch.turn_off
mode: restart

The switch is a 3-way Tasmota switch created by the following entry in configuration.yaml and works fine from the entities screen

mqtt:
  switch:
     - unique_id: study_lights
      name: "Study Lights"
      state_topic: "stat/TreatLife4/POWER1"
      command_topic: "cmnd/TreatLife4/EVENT"
      payload_on: "ON"
      payload_off: "OFF"
      availability_topic: "tele/TreatLife4/LWT"
      payload_available: "Online"
      payload_not_available: "Offline"

Check the traces for your automation when this happens. It will tell you exactly what’s going on.

If I had to guess, I’d say it’s the motion sensors detecting motion again while the light is still on.
Since your automation is set to restart, the delay starts all over again.