Repeat until - condition was (not is)

Current automation config requires the light to be is_on when repeat loop resets
Is it possible to have the condition be met when the light was_on in the last 5 minutes?

alias: Washing Machine
description: ''
trigger:
  - type: power
    platform: device
    device_id: xxx
    entity_id: sensor.power
    domain: sensor
    below: 4
    for:
      hours: 0
      minutes: 5
      seconds: 0
condition:
  - condition: or
    conditions:
      - condition: state
        entity_id: person.xxx2
        state: home
      - condition: state
        entity_id: person.xxx
        state: home
action:
  - repeat:
      until:
        - condition: device
          type: is_on
          device_id: xxx
          entity_id: light.laundry
          domain: light
      sequence:
        - service: tts.cloud_say
          data:
            entity_id: media_player.all_speakers
            message: Wet washing in the washing machine.
        - delay:
            hours: 0
            minutes: 5
            seconds: 0
            milliseconds: 0
mode: single

Use a template condition for the repeat loop.

Something like:

{{ is_state('light.laundry', 'on') and (as_timestamp(now()) | float - as_timestamp(states.light.laundry.last_changed) | float) > 300 }}

So (on now) or (on in the last five minutes but off now)?

action:
  - repeat:
      until:
        - condition: or
          conditions:
            - "{{ states('light.laundry', 'on') }}"
            - "{{ states('light.laundry', 'off') and ( now().timestamp() - as_timestamp(states.light.laundry.last_changed) < 300  )  }}"

Working solution:

              value_template: >-
                {{ as_timestamp(now()) -
                as_timestamp(states.light.laundry.last_changed) <300}}

Although, I couldnt get it to work with the on condition also. This will likely work 99.9% of the time.