Timer Example: Auto re-lock front door after 5min

Hope someone’ll find this helpful. I finally got around to using a timer rather than scripts with delays to handle re-locking my front door. I’ve got a zwave lock on the door and use the Eanvisalink component to tell when my front door is opened. I also have an input_boolean to keep track of whether I’ve got a house guest (keeps the system from locking my inlaws out, etc). You can adapt the details to fit your situation.

- alias: Start Front Door Autolock Timer
  trigger:
    - platform: state
      entity_id: lock.front_door_deadbolt
      to: 'unlocked'
    - platform: state
      entity_id: binary_sensor.front_door
      to: 'off'
  action: 
    - service: timer.start
      entity_id: timer.front_door_lock
      data:
        duration: '00:05:00'
      
- alias: Pause Front Door Autolock Timer
  trigger:
    - platform: state
      entity_id: binary_sensor.front_door
      to: 'on'
  action: 
    - service: timer.pause
      entity_id: timer.front_door_lock
      
- alias: Cancel Front Door Autolock Timer
  trigger:
    - platform: state
      entity_id: lock.front_door_deadbolt
      to: 'locked'
  action: 
    - service: timer.cancel
      entity_id: timer.front_door_lock

- alias: Auto Lock Front Door
  trigger: 
    - platform: event
      event_type: timer.finished
      event_data: 
        entity_id: timer.front_door_lock
  condition:
    condition: state
    entity_id: input_boolean.house_guest
    state: 'off'
  action:
    - service: lock.lock
      entity_id: lock.front_door_deadbolt
7 Likes

Very useful, thanks for sharing.

Nice @ih8gates ! I have a very similar automation myself, biggest difference is my usage of conditions.

- alias: Timer Start Auto Lock
  trigger:
  - platform: state
    entity_id: lock.front_door_lock_locked
    to: 'unlocked'
  - platform: state
    entity_id: binary_sensor.centralite_3320l_057b833c_1
    to: 'off'
  condition:
    condition: and
    conditions:
    - condition: state
      entity_id: binary_sensor.centralite_3320l_057b833c_1
      state: 'off'
    - condition: state
      entity_id: lock.front_door_lock_locked
      state: 'unlocked'
  action:
  - service: timer.start
    entity_id: timer.door_lock

- alias: Cancel Timer Door Locked
  trigger:
  - platform: state
    entity_id: lock.front_door_lock_locked
    to: 'locked'
  - platform: state
    entity_id: binary_sensor.centralite_3320l_057b833c_1
    to: 'on'
  action:
  - service: timer.cancel
    entity_id: timer.door_lock

- alias: Auto Lock Front Door
  trigger:
  - platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.door_lock
  condition:
    condition: state
    entity_id: binary_sensor.centralite_3320l_057b833c_1
    state: 'off'
  action:
  - service: lock.lock
    entity_id: lock.front_door_lock_locked
1 Like

Hi all,

I was wondering what kind of hub you have for connecting the zwave lock.

I have a Schlage Connect (zwave model) connected to the Wink2 hub, but can only see the state of it and cannot see it or any other Wink device in the dropdown list of devices in the automation wizard.

Aeotec Z-stick