Automation to lock the door after X minutes

Attempting to automate the locking of the back door. a) I’m lazy that way :stuck_out_tongue_winking_eye: b) Spouse is forgetful

Worked it out in the Developer Tools template editor, plopped that into an automation, and (of course!) the automation does not fire. I presume I’ve overlooked something rather simple. The desired behavior is this: If the door is closed (alarm sensor value) and the lock is unlocked (lock device value) for more than X minutes, then lock the lock.

Here’s the code:

- id: '12345678'
  alias: Sunroom Door - Lock after XX minutes
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.sunroom_door
    to: closed
    for:
      hours: 0
      minutes: 2
      seconds: 0
      milliseconds: 0
  condition:
  - condition: template
    value_template: "{{ states('binary_sensor.sunroom_door') == 'off' and states('lock.sunroom_door_lock') == 'unlocked' }}"
  action:
  - service: lock.lock
    target:
      entity_id:
      - lock.sunroom_door_lock
  mode: single

binary_sensor entities can only be on or off. The UI turns that into something more human-readable like “open” or “closed”, but you can see the real state in Dev Tools->States. Your template in the condition already reflects that:

states('binary_sensor.sunroom_door') == 'off'

Was just seeing the difference and about to post the same thing. :frowning:
One of the things that always gets me is how it appears in HA versus how it must be automated.
Thank you, @rccoleman for your kind assistance!