How to use Automation editor to create auto lock timer?

Looking for a few ideas about how to approach a timer for my Schlage lock. What I essentially want to do is have the door lock itself if it has been unlocked for 15 minutes…

I can get part of the way there, but when it comes to setting a timer, I select time, from the drop down menu and I get At: which I do not want to designate a specific time, just one in relation to the unlocking trigger of the door. My best guess would be to have an automation that triggers on the unlock and then action to lock… offset by 15 minutes. But I am not sure how that would look… I don’t want the lock to behave like a dimmer and lock in slow motion. :smile:

I don’t believe this is supported by the automation UI yet. The proper way is:

trigger:
  platform: state
  entity_id: lock.front_door
  to: "off"
  for:
    minutes: 15

However, it doesn’t seem that the automation editor supports the “for” yet.

I don’t use hass.io but do it in a similar way to the kitchen light motion timer. The idea is to trigger a script when the door unlocks that will lock the door after 15 min. I have conditions in the script like the door must be closed. I also reset the script if motion is detected outside or if the door is reopened and have the porch light on if its unlocked.

Thanks for the hints on automation. I’ll definitely use this help, and report back! I’ve only started with hass.io so I’ll try to familiarize myself more with the direct input into my automation.yaml file.

That is a really good bit of fact. I didn’t realize I was looking for something that may not be implemented yet in the UI. Thanks!

Finally got something together that seems to work. It’s simple and does what I need it to do since there is no real condition in my house to have the door remain unlocked with little ones running around. If I get a door sensor, I may change that up as a condition to not lock and notify if the door is ajar, like I see in some examples.

This what my automation looks like:

- alias: "Front door has locked automatically"
  trigger:
    platform: state
    entity_id: lock.front_door_lock
    from: 'locked'
    to: 'unlocked'
  action:
    - delay: '00:15:00'
    - service: lock.lock
      entity_id:
        - lock.front_door_lock
    - service: notify.ios_iphonese
      data:
        message: 'Front door has locked'

How would you recommend adding a condition for the door to be closed as well.

Maybe make the trigger open close sensor changes to closed (door would have to be unlocked for that to happen), then do the delay.

Here is my question about automations, what if the door is opened again before the timer counts down, would the timer start over?

I’m going to play around with this with a open/close and post my results.

Look forward to seeing those results when you do the tests.

1 Like

Thanks for the reminder. I just did the test. Every time I opened the door the timer reset. Which is what i hoped would happen. I did create a second automation to lock the door if it was unlocked but never opened. Not a common occurrence but still a possibility.

Here is what I have ended up with. This will work if the lock is unlocked but door never opened, or if the door is opened and then closed. Will keep the lock from locking if the door is open.

  trigger:
  - platform: state
    entity_id: lock.front_door_lock
    from: 'locked'
    to: 'unlocked'
    for:
      minutes: 5  
  - platform: state
    entity_id: binary_sensor.centralite_3320l_0cceb5ca_1_1280
    from: 'on'
    to: 'off'
    for:
      minutes: 5
  condition:
  - condition: state
    entity_id: binary_sensor.centralite_3320l_0cceb5ca_1_1280
    state: 'off'
    for:
      minutes: 4
  action:
  - service: lock.lock
    entity_id: lock.front_door_lock
1 Like