Lights with door sensor

Hi!
Can somebody help me with automation in Esphome?``.I have door sensor and a switch in my esp32 yaml.And right now the door sensor toggles a switch only when door opens.(open the door to enter to toilet,switch turns on ,closing the door,switch does nothing,and whel i leavs toilet-open the door again,switch turns off.Works nice and perfect.Now i need to add automation,if door is open longer than 10 sec and door closes, the switch turning off.
sorry about my english.

- platform: gpio
    pin:
      number: 3
      mode: INPUT_PULLUP
    name: "Wcukseandur"
    id: "wcukseandur"
    device_class: door
    #uks avaneb
    on_press:
      then:
        - switch.toggle: wcuks

Have you tried the for condition? Automations and Templates — ESPHome

Something like this:

on_press:
      then:
        - switch.toggle: wcuks
        if: 
          condition: 
            for:
              time: 10s
              condition:
                switch.is_on: "wcukseandur"
          then:
            - switch.turn_off: wcuks

Nope,still just toggling

try this

Toilet Exhaust Fan with time delay

Solved by myself.Thanx anyway !

 - platform: gpio
    pin:
      number: 3
      mode: INPUT_PULLUP
    name: "Wcukseandur"
    id: "wcukseandur"
    device_class: door
   
    on_press:
      then:
        - switch.toggle: wcuks
        - delay: 5s
        - if: 
            condition: 
              lambda: 'return id(wcukseandur).state == true;'
            then:
              - wait_until:
                  binary_sensor.is_off: wcukseandur
              - switch.turn_off: wcuks
            else:
              - switch.turn_on: wcuks

This is not EspHome

Sorry,guys.Right solution is here.

 - platform: gpio
    pin:
      number: 3
      mode: INPUT_PULLUP
    name: "Wcukseandur"
    id: "wcukseandur"
    device_class: door
    #uks avaneb
    on_press:
      then:
        - switch.toggle: wcuks
        - delay: 5s
        - if: 
            condition: 
              lambda: 'return id(wcukseandur).state == true;'
            then:
              - wait_until:
                  binary_sensor.is_off: wcukseandur
              - switch.turn_off: wcuks