Skip to content

Commit

Permalink
retry autolock in 30 seconds if door sensor shows door is open
Browse files Browse the repository at this point in the history
  • Loading branch information
FutureTense committed Aug 10, 2021
1 parent fd23e96 commit f7cac62
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 4 deletions.
26 changes: 24 additions & 2 deletions custom_components/keymaster/keymaster_common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,18 @@ script:
{ "node": {{ node_id }} }
retain: true

keymaster_LOCKNAME_start_timer_retry:
sequence:
- condition: state
entity_id: LOCKENTITYNAME
state: 'unlocked'
- service: timer.cancel
entity_id: timer.keymaster_LOCKNAME_autolock
- service: timer.start
data_template:
entity_id: timer.keymaster_LOCKNAME_autolock
duration: 00:00:30

keymaster_LOCKNAME_start_timer:
sequence:
- condition: state
Expand Down Expand Up @@ -278,8 +290,18 @@ automation:
event_data:
entity_id: timer.keymaster_LOCKNAME_autolock
action:
- service: lock.lock
entity_id: LOCKENTITYNAME
- choose:
- conditions:
- condition: template
value_template: "{{ (states('DOORSENSORENTITYNAME') != 'on') }}"
sequence:
- service: lock.lock
entity_id: LOCKENTITYNAME
- conditions:
- condition: template
value_template: "{{ (states('DOORSENSORENTITYNAME') == 'on') }}"
sequence:
- service: script.keymaster_LOCKNAME_start_timer_retry

- alias: keymaster_LOCKNAME_disable_auto_lock
trigger:
Expand Down
26 changes: 24 additions & 2 deletions custom_components/keymaster/keymaster_common_child.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,18 @@ script:
{ "node": {{ node_id }} }
retain: true

keymaster_LOCKNAME_start_timer_retry:
sequence:
- condition: state
entity_id: LOCKENTITYNAME
state: 'unlocked'
- service: timer.cancel
entity_id: timer.keymaster_LOCKNAME_autolock
- service: timer.start
data_template:
entity_id: timer.keymaster_LOCKNAME_autolock
duration: 00:00:30

keymaster_LOCKNAME_start_timer:
sequence:
- condition: state
Expand Down Expand Up @@ -278,8 +290,18 @@ automation:
event_data:
entity_id: timer.keymaster_LOCKNAME_autolock
action:
- service: lock.lock
entity_id: LOCKENTITYNAME
- choose:
- conditions:
- condition: template
value_template: "{{ (states('DOORSENSORENTITYNAME') != 'on') }}"
sequence:
- service: lock.lock
entity_id: LOCKENTITYNAME
- conditions:
- condition: template
value_template: "{{ (states('DOORSENSORENTITYNAME') == 'on') }}"
sequence:
- service: script.keymaster_LOCKNAME_start_timer_retry

- alias: keymaster_LOCKNAME_disable_auto_lock
trigger:
Expand Down

0 comments on commit f7cac62

Please sign in to comment.