Unlock door when coming home, but lock again if door sensor not triggered within 3 minutes

I have gotten an automation to work that works for unlocking the door when arriving home:

- id: '1641634381082'
  alias: Lås dør op
  description: ''
  trigger:
  - platform: state
    entity_id: input_boolean.house_mode
    from: 'off'
    to: 'on'
  condition:
  - condition: state
    entity_id: lock.danalock
    state: locked
  action:
  - service: lock.unlock
    target:
      entity_id: lock.danalock
  mode: single

But I would like to add a condition that unless our door sensor (“binary_sensor.openclose_12”) goes from off to on within 2 minutes, then the door should lock again as a security precaution.

How do I add this condition? It cannot be a wait and check after 2 minutes, because then I can have had the door open but closed again, it needs to check during the 2 minutes duration and stop the timer if the condition is met.

The next action should be to wait for a trigger (state change of your sensor). Set a timeout of 2 min, then check if the trigger was fired. If not lock the door.