Sonoff Basic PIR sensor AM312 delay off

Hello!
I have a Sonoff Basic R2 with a AM 312 motion sensor and my goal is to let the motion sensor turn on the switch for 5 minutes as long as there is motion detected,
So if motion is detetcted after 3 minutes, it should keep the switch on for another 5 minutes,

This is my current code:

esphome:
  name: sonoffbasic5
  platform: ESP8266
  board: esp01_1m

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: !secret http_password

ota:
  password: !secret http_password

binary_sensor:
  - platform: gpio
    pin: GPIO3
    name: "PIR Sensor sbasic5"
    id: pirsbasic5
    device_class: motion
    on_press:
      then:
       - switch.turn_on: relay
       - delay: 300s
       - swith.turn_off: relay

switch:
  - platform: gpio
    name: "sbasic5"
    pin: GPIO12
    id: relay


status_led:
  pin:
    number: GPIO13
    inverted: yes

It only works the first 5 minutes.

Do I need somehing like this?

#  - platform: template
#    lambda: 'return id(pirsbasic5).state;'
#    filters:
#      - delayed_off: 5min
#    on_release:
#      then:
#        - switch.turn_off: relay