I added a Xfinity XHK1-UE Zigbee Keypad to my Home Assistant configuration, but found that the new keypad functions independently of the main home alarm functionality that is built into HA (alarm_control_panel.home_alarm
). That makes sense in many ways, and makes keypads more flexible, but it wasn’t what I initially expected.
I expected that the keypad would synchronize with the home alarm so that when I armed or disarmed the keypad, the home alarm would also arm or disarm. Maybe there is something wrong with my configuration, or there is an easier way to do this, and if so, I’m interested in hearing about it. However, this is the way that I’ve accomplished linking keypads to the home alarm and I hope it might be useful to someone else.
My solution uses a Python script and a separate automation for each keypad:
- Add the
python_script:
section toconfiguration.yaml
- Create a folder
<config>/python_scripts
- Create a file
link_alarm_keypad.py
in thepython_scripts
folder and add this script to the file:
HOME_ALARM_ENTITY_ID = "alarm_control_panel.home_alarm"
ALARM_STATUS_TO_ACTIONS = {
"armed_away": "alarm_arm_away",
"armed_home": "alarm_arm_home",
"armed_night": "alarm_arm_night",
"disarmed": "alarm_disarm",
}
def translate_alarm_status(alarm_status, destination_entity_id, alarm_code):
destination_status = hass.states.get(destination_entity_id).state
if destination_status != alarm_status:
alarm_action = ALARM_STATUS_TO_ACTIONS.get(alarm_status, "")
if alarm_action != "":
service_data = {"entity_id": destination_entity_id, "code": alarm_code}
hass.services.call("alarm_control_panel", alarm_action, service_data)
trigger_entity_id = data.get("entity_id")
trigger_status = hass.states.get(trigger_entity_id).state
alarm_code = data.get("alarm_code")
if trigger_entity_id == HOME_ALARM_ENTITY_ID:
keypad_entity_id = data.get("keypad_entity_id")
translate_alarm_status(trigger_status, keypad_entity_id, alarm_code)
else:
translate_alarm_status(trigger_status, HOME_ALARM_ENTITY_ID, alarm_code)
- Restart Home Assistant or use YAML configuration reloading in the Server Controls to reload the Python configuration and scripts.
- Add a separate automation for each keypad with the following YAML configuration:
alias: Link Alarm Keypad #1
description: ''
trigger:
- platform: state
entity_id: alarm_control_panel.home_alarm
- platform: state
entity_id: alarm_control_panel.keypad_name_xxxx_ias_ace
condition: []
action:
- service: python_script.link_alarm_keypad
data:
entity_id: '{{ trigger.entity_id }}'
alarm_code: '1234'
keypad_entity_id: alarm_control_panel.keypad_name_xxxx_ias_ace
mode: queued
max: 10
- Substitute
#1
with a number (or name of the keypad) to distinctively name the automation - Substitute the code in
alarm_code: '1234'
with thecode
value used in thealarm_control_panel
section ofconfiguration.yaml
- Substitute
alarm_control_panel.keypad_name_xxxx_ias_ace
with the entity used in the keypad device for control. It will probably have the suffix,ias_ace
(for Intruder Alert System Ancillary Control Equipment)
Now, if everything is working correctly, you can arm or disarm the main home alarm system using any keypad, and the changes will be reflected on each keypad and the dashboard.