Loop keep running even after condition is fulfilled

Help Please,
This is a general reminder to send notice when any of the doors has opened more than 30 minutes.
It can be triggered and send corresponding notice, the only question is it can not stop even the door is closed.
I cannot figure out why.

alias: "Reminder: long door open"
description: Door has been opened for a long time
trigger:
  - platform: state
    entity_id:
      - binary_sensor.garage_door_sensor
      - binary_sensor.door_contact_sensor_4f9f
      - binary_sensor.door_contact_sensor_4ee1
    to: "on"
    for:
      hours: 0
      minutes: 30
      seconds: 0
condition: []
action:
  - repeat:
      until:
        - condition: template
          value_template: "{{ is_state(trigger.to_state.state, \"off\") }}"
      sequence:
        - service: notify.pixelGroup
          data:
            title: "{{ area_id(trigger.entity_id) }}"
            message: The door has been open for a long time.
        - delay:
            hours: 0
            minutes: 10
            seconds: 0
            milliseconds: 0
  - service: notify.pixelgroup
    data:
      message: Door is closed.
      title: OK
mode: single

This condition doesn’t make any sense. If the automation triggered then that means the value of trigger.to_state.state equals on. So this template is the same as the one in your until:

{{ is_state('on', 'off') }}

That’s never going to evaluate to true. So your loop is never going to stop.

I think you meant to use this as the template for until:

{{ is_state(trigger.entity_id, 'off') }}

So it stops looping when the entity that triggered the automation by being on is now off

I am going to try your code. Thank you so much
I will let you know the result asap.

By the way, in order to use your code below:

    data:
      entity_id: script.reminder_long_door_open

My code is in automation. How to refer to this automation? And can we use the this keyword here?

I think you are right.
I meant to judge the state of the entity which triggered the loop, but I used the wrong object. I should use {{ is_state(trigger.entity_id, 'off') }} .
Thanks a lot.

I have another related question:
Door 1 opened, which triggered the loop, then door 2 opened, then door 1 closed, what will happen? Can the trigger object represent more than one entity?
Or I should change the mode to parallel?