Help with lock automation

New Home Assistant user, I recently moved from Vera and so far so good! I could use a little help with an automation. I have a z-wave deadbolt (using keymaster) with a Aeotec recessed door sensor on my front door. My goal is form 22:00 to 06:30 everyday to have the door automatically lock after being closed for 5 minutes. I want the automation to make certain the door is closed before the lock is triggered. The automation I created only works if the door is open after 22:00 and I close it, if the door is already closed it does not work. If someone could offer up a solution I would be grateful. I would also like the door to relock if opened during the set time frame (which it currently does).

alias: Front Door Auto Lock 22:00
description: ""
trigger:
  - type: not_opened
    platform: device
    device_id: 5c91cb157ec1d329605dc48654262d31
    entity_id: binary_sensor.front_door_sensor_sensor_state_any
    domain: binary_sensor
    for:
      hours: 0
      minutes: 5
      seconds: 0
condition:
  - condition: time
    before: "06:30:00"
    after: "22:00:00"
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
      - sun
action:
  - device_id: 8676a6b95bb854c4847b83825588ce58
    domain: lock
    entity_id: lock.front_door_deadbolt
    type: lock
mode: single

Add a trigger with time 22:00.

Moved. Please read the channel topics. Community Guides is for writing “how-to” articles not for asking for help.