Instantly share code, notes, and snippets.
Last active Jan 9, 2022
This copy of the Blueprint is no longer maintained, and is deprecated. It might be removed at any time. Look here to find the current versions: ```https://github.com/SirGoodenough/HA_Blueprints/blob/master/README.md```
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blueprint: | |
name: Keypad 5 button cypher to turn on something_2021-11-20 | |
description: This will accept any 5 button presses or binary sensor detections and use them to preform an action. RE open a lock, or whatever. | |
# Community link for blueprint: source_url: https://community.home-assistant.io/t/keypad-cipher-code-for-5-button-presses-before-you-turn-on-an-input-boolean/322385 | |
source_url: https://gist.github.com/SirGoodenough/fbd552e2c93ebaa5c9b3d2b4ebff3297 | |
domain: automation | |
homeassistant: | |
min_version: 2021.7.0 | |
input: | |
button_one: | |
name: Button Press One | |
description: Binary Sensor for First Button Pressed | |
selector: | |
entity: | |
domain: binary_sensor | |
button_two: | |
name: Button Press Two | |
description: Binary Sensor for Second Button Pressed | |
selector: | |
entity: | |
domain: binary_sensor | |
button_three: | |
name: Button Press Three | |
description: Binary Sensor for Third Button Pressed | |
selector: | |
entity: | |
domain: binary_sensor | |
button_four: | |
name: Button Press Four | |
description: Binary Sensor for Forth Button Pressed | |
selector: | |
entity: | |
domain: binary_sensor | |
button_five: | |
name: Button Press Five | |
description: Binary Sensor for Fifth Button Pressed | |
selector: | |
entity: | |
domain: binary_sensor | |
lock_control: | |
name: Buffer for the Final Lock Enable | |
description: input_boolean - Final Enable to trigger your lock or action | |
selector: | |
entity: | |
domain: input_boolean | |
seq_status: | |
name: Control Sequence Status Placeholder | |
description: >- | |
input_number - The internal use lock sequence number (set range to 0 to 100) | |
You will need one of these for every copy of this automation, | |
IE one for every lock code. | |
selector: | |
entity: | |
domain: input_number | |
on_timer: | |
name: Lock On Time in Seconds | |
description: Time output signal is on in seconds. Generally 5 seconds is good here. | |
default: 60 | |
selector: | |
number: | |
min: 5.0 | |
max: 360.0 | |
unit_of_measurement: seconds | |
mode: slider | |
step: 1.0 | |
variables: | |
seq_status_ent: !input 'seq_status' | |
seq_status_last: '{{ expand(seq_status_ent)[0].last_changed | as_timestamp }}' | |
seq_status_val: '{{ expand(seq_status_ent)[0].state }}' | |
tnow: '{{ as_timestamp(now()) }}' | |
mode: single | |
max_exceeded: silent | |
trigger: | |
- platform: state | |
entity_id: !input 'button_one' | |
id: pad1 | |
from: 'off' | |
to: 'on' | |
- platform: state | |
entity_id: !input 'button_two' | |
id: pad2 | |
from: 'off' | |
to: 'on' | |
- platform: state | |
entity_id: !input 'button_three' | |
id: pad3 | |
from: 'off' | |
to: 'on' | |
- platform: state | |
entity_id: !input 'button_four' | |
id: pad4 | |
from: 'off' | |
to: 'on' | |
- platform: state | |
entity_id: !input 'button_five' | |
id: pad5 | |
from: 'off' | |
to: 'on' | |
action: | |
# This one is always run every trigger as the watchdog. | |
- alias: Reset seq number to 99 if timeout occurred | |
service: input_number.set_value | |
data: | |
entity_id: !input seq_status | |
value: > | |
{% if seq_status_last < tnow - (5*60) %} | |
{# It's been too long so reset the sequence #} | |
99 | |
{% else %} | |
{# Timing is good, so accept the value set #} | |
{{ seq_status_val }} | |
{% endif %} | |
- choose: | |
- alias: Somebody pushed the first button | |
conditions: | |
- condition: trigger | |
id: pad1 | |
sequence: | |
- alias: Set seq number to 1 | |
service: input_number.set_value | |
data: | |
entity_id: !input seq_status | |
value: 1 | |
- alias: Button 2 pushed in correct sequence number order | |
conditions: | |
- condition: and | |
conditions: | |
- condition: trigger | |
id: pad2 | |
- condition: template | |
value_template: '{{ is_state( seq_status_ent, ''1.0'') }}' | |
sequence: | |
- alias: Set seq number to 3 | |
service: input_number.set_value | |
data: | |
value: 3 | |
target: | |
entity_id: !input seq_status | |
- alias: Button 3 pushed in correct sequence number order | |
conditions: | |
- condition: and | |
conditions: | |
- condition: trigger | |
id: pad3 | |
- condition: template | |
value_template: '{{ is_state( seq_status_ent, ''3.0'') }}' | |
sequence: | |
- alias: Set seq number to 7 | |
service: input_number.set_value | |
data: | |
value: 7 | |
target: | |
entity_id: !input seq_status | |
- alias: Button 4 pushed in correct sequence number order | |
conditions: | |
- condition: and | |
conditions: | |
- condition: trigger | |
id: pad4 | |
- condition: template | |
value_template: '{{ is_state( seq_status_ent, ''7.0'') }}' | |
sequence: | |
- alias: Set seq number to 15 | |
service: input_number.set_value | |
data: | |
value: 15 | |
target: | |
entity_id: !input seq_status | |
- alias: Button 5 pushed in correct sequence number order | |
conditions: | |
- condition: and | |
conditions: | |
- condition: trigger | |
id: pad5 | |
- condition: template | |
value_template: '{{ is_state( seq_status_ent, ''15.0'') }}' | |
sequence: | |
- alias: Set seq number to 31 | |
service: input_number.set_value | |
data: | |
value: 31 | |
target: | |
entity_id: !input seq_status | |
- alias: Enable the Lock | |
service: input_boolean.turn_on | |
entity_id: !input lock_control | |
- alias: Leave the lock enabled for a time limit | |
delay: !input on_timer | |
- alias: Disable the Lock normal | |
service: input_boolean.turn_off | |
entity_id: !input lock_control | |
- alias: Reset status number normal | |
service: input_number.set_value | |
data: | |
value: 0 | |
target: | |
entity_id: !input seq_status | |
default: | |
- alias: Reset status number on fail code | |
service: input_number.set_value | |
data: | |
value: 0 | |
target: | |
entity_id: !input seq_status | |
- alias: Shut it down on fail code | |
service: input_boolean.turn_off | |
entity_id: !input lock_control |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This copy of the Blueprint is no longer maintained, and is deprecated.
It might be removed at any time.
Look here to find the current versions:
https://github.com/SirGoodenough/HA_Blueprints/blob/master/README.md