One of the main reasons I purchased a LocalDeck for is to use it as an alarm keypad.
I have this now working - so I thought I’d share it as an unusual example of using a LocalDeck.
In Home Assistant I am using the Alarmo integration to work with door sensors, motion sensors, sirens and lights to form an alarm system. We have been using our old alarm system for 15 years or so and have gotten used to arming and disarming it by entering our codes into a keypad inside the front door. While we can, and do, use the Home Assistant app on our phones for the new Alarmo alarm, I need to replicate the keypad to gain a higher wife acceptance level as we don’t always have our phones ready at hand when we walk in or out of the house and want to set the alarm - and then its a mad scramble to find a device, open the app, navigate to the right dashboard and enter the code all while the alarm is blaring and the lights flashing.
So, I have set aside half my LocalDeck keys to give me a keypad in a mobile phone style layout with the numbers 0..10, a clear key, and an enter key.
I’ve then modified the ESPHome YAML file to include a ‘key collector’ component that collects the alarm code we enter and sends it to Home Assistant after we press eneter, then two seconds later clears it - this is so the alarm code is not hanging around and still readily visible in Home Assistant
# Adding key collector before all the sensor / lights code
# This collects up to four key presses - waits for the 'end key'
# Sends it to Home assistant
# Waits for a bit and then resets the key code back to zero
key_collector:
- id: alarm_code_reader
source_id: keypad
min_length: 4
max_length: 8
end_keys: "F"
end_key_required: True
clear_keys: "D"
allowed_keys: "DEFJKLPQRVWX"
timeout: 4s
on_result:
- text_sensor.template.publish:
id: alarm_code
state: !lambda "return x.c_str();"
- delay: 2s
- text_sensor.template.publish:
id: alarm_code
state: ""
There is also a small edit in the on-boot section of the LocalDeck YAML to reset any old codes when booting
on_boot:
# It is used to force an alarm code reset on boot
- text_sensor.template.publish:
id: alarm_code
state: ""
I also needed to add a text_sensor to hold, and transmit, the entered alarm code to Home Assistant
This edit to the YAML is a bit problematic as if you subsequently use the LocalDeck configurator it gets deleted and you have to manually add it again before compiling and uploading it to the LocalDeck
text_sensor:
# Used to send the collected alarm code keys to Home assistant
- platform: template
name: alarm panel code
id: alarm_code
update_interval: never
In Home Assistant I then have an automation that is triggered when ever this new alarm_panel_code is entered
The Automation passes the code through to Alarmo to either arm or disarm the alarm, or ignores it if it was set to blank. Alarmo checks if the entered code is correct, and the LocalDeck has its own individual code
alias: Process alarm code entered on keypad
description: ""
trigger:
- platform: state
entity_id:
- sensor.localdeck_411a68_alarm_panel_code
condition:
- condition: not
conditions:
- condition: state
entity_id: sensor.localdeck_411a68_alarm_panel_code
state: ""
action:
- choose:
- conditions:
- condition: state
entity_id: alarm_control_panel.house
state: disarmed
sequence:
- service: alarmo.arm
data:
entity_id: alarm_control_panel.house
code: "{{ states('sensor.localdeck_411a68_alarm_panel_code') }}"
mode: away
skip_delay: false
- conditions:
- condition: not
conditions:
- condition: state
entity_id: alarm_control_panel.house
state: disarmed
sequence:
- service: alarmo.disarm
data:
entity_id: alarm_control_panel.house
code: "{{ states('sensor.localdeck_411a68_alarm_panel_code') }}"
I’ve then got some further scripts in Home Assistant called by Alarmo to set the LocalDeck LEDs behind the ‘keypad’ keys according to the alarm status. For example when you enter the house with the alarm armed it lights the keypad up in white so you can easily find it in the dark and enter your code. If the code you entered succesfully disarms the alarm it indicates this by flashing the keys green, if not you are in a world of red!
alias: Flash keypad keys Green
description: ""
icon: mdi:alarm-light-outline
sequence:
- service: script.turn_on
entity_id: script.turn_keypad_keys_green
- delay:
seconds: 5
- service: script.turn_on
entity_id: script.turn_keypad_keys_lights_off
The ‘turn_keypad_keys_green’ script referenced above is long and convoluted (and therefore not reproduced here) because it animates the LocalDeck lights over a second or so and sets the centre of the keypad brighter than edges.
I’m only new at ESPHome and Home Assistant so please forgive me if my methods are not as neat and tidy as they could be.
It would be great if there could be a future modification to how the LocalDeck configurator works to neeatly allow the inclusion / retaining of the ‘text_sensor’, or other ’below the line additions, in the YAML
regards
Andrew
Lerderderg, Australia