Skip to content

Instantly share code, notes, and snippets.

@ahutchings
Last active April 2, 2024 04:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ahutchings/9ec7db38323c2b02db075bd12bf4dcad to your computer and use it in GitHub Desktop.
Save ahutchings/9ec7db38323c2b02db075bd12bf4dcad to your computer and use it in GitHub Desktop.
Home Assistant Blueprint: Auto-Lock Door
blueprint:
name: Auto-Lock Door
description: "Auto-lock a door when it is closed and unlocked."
domain: automation
source_url: https://gist.github.com/ahutchings/9ec7db38323c2b02db075bd12bf4dcad
input:
door_lock:
name: Door Lock
selector:
entity:
domain: lock
door_sensor:
name: Door Sensor
selector:
entity:
domain: binary_sensor
device_class: door
delay:
name: Delay
description: Delay before locking the door.
default: 30
selector:
number:
min: 0
max: 180
unit_of_measurement: seconds
alias: Auto-Lock Door
description: "Auto-lock a door when it is closed and unlocked."
trigger:
- platform: state
entity_id: !input door_sensor
to: "off"
for:
seconds: !input delay
- platform: state
entity_id: !input door_lock
to: unlocked
for:
seconds: !input delay
condition:
- condition: state
entity_id: !input door_lock
state: unlocked
- condition: state
entity_id: !input door_sensor
state: "off"
action:
- service: lock.lock
target:
entity_id: !input door_lock
mode: single
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment