Link Keypad and Main Alarm Control Panel

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:

  1. Add the python_script: section to configuration.yaml
  2. Create a folder <config>/python_scripts
  3. Create a file link_alarm_keypad.py in the python_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)
  1. Restart Home Assistant or use YAML configuration reloading in the Server Controls to reload the Python configuration and scripts.
  2. 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 the code value used in the alarm_control_panel section of configuration.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.

1 Like

Hello,

First I want to give you a big thank you because I just bought the keypad and received 2 days ago and you gave exactly what I needed !

I will ask a question, just in case, do you know if there is a way to use the native beep/chime from the keypad ?

I’ve read in original Xfinity manual that the keypad has this feature, but it seems not handled by HA.
It also has the beep/chime feature when a door sensor triggers…

Currently I plan to buy a small jack speaker and plug it on the raspberry pi with MPD addon to play a sound…
It does the trick but It would be cool to have the native “arming/pending” from the keypad.

Thank you !

My keypad only beeps during button presses and a very brief arming beep. I assume you mean the countdown beeps that let a person know they need to take action (either leave during arming, or disarm after entering).

Unfortunately the ZHA device handlers don’t expose everything about my keypad, so the beeping functionality of the keypad is not really available. The battery level doesn’t even work properly on mine yet…

I use another device to provide audio warnings. My cameras can play audio files, and I also have a siren that can play warning tones. Personally, I’d avoid having the HA device (like your Raspberry Pi) beep because the noise might point someone to it and they could grab and unplug it before it can perform the alarm automations.

Yes I agree about the speaker, i’ll check to give it a long cord between raspberry pi and speaker, but the raspberry pi will be hidden by the way.

Same for me, battery level is KO too.

Hello,
Has anyone gotten this to work with the alarmo integration?

I followed the steps above but replaced HOME_ALARM_ENTITY_ID = “alarm_control_panel.home_alarm” in the python script with HOME_ALARM_ENTITY_ID = “alarm_control_panel.alarmo”. Also changed it to alarmo in the automation for the trigger.

But it doesn’t seem to work. I’ve never used python scripts in HA so i am not sure where to start with debugging this.

Any suggestions and help welcome. Thank you!

Did you ever have any luck getting this to work with Alarmo? Would love to have the Xfinity keypad integrated with Alarmo to complete my system.

No unfortunately, I gave up and just created automations to sync the status. That solution has been working without issue so I stopped looking into this script.

Thanks for the reply! So you are able to sync the status of Alarmo with your Xfinity XHK1-UE just utilizing automations? That sounds much simpler. Are you using ZHA or Z2M?

Yes you can. I am using ZHA with a sonoff ZigBee 3.0 dongle on a rpi4.

Here is one of my automations in yaml form. I created it with the visual editor so I didn’t have to determine the device id and formatting.

alias: Alarm Keypad - Alarmo to Keypad Link - Arm Away
description: ''
trigger:
  - platform: state
    entity_id: alarm_control_panel.alarmo
    to: armed_away
condition: []
action:
  - service: alarm_control_panel.alarm_arm_away
    data: {}
    target:
      device_id: 86045055ffab51cfb21e95131327a637
mode: single

This automation changes the keypad state to armed_away whenever alarmo state is changed to arm away.
You need another automation to sync it the reverse way so if you arm it from the keypad it syncs back to alarmo. You need to recreate those 2 automations for all arm modes you are using. I only use arm home and arm away. Then you also need 2 automations for when you disarm one of the panels, for these you will need to use a code, I hope to find a way to put this code in a secret file, but for now it’s just plaintext in the automation. Here is an example of my disarm automation.

alias: Alarm Keypad - Keypad to Alarmo Link - Disarmed
description: ''
trigger:
  - platform: state
    entity_id: alarm_control_panel.keypad_system
    to: disarmed
condition: []
action:
  - service: alarm_control_panel.alarm_disarm
    data:
      code: '1111'
    target:
      device_id: f0eedd763a1e488fc7d6f2a869201a45
mode: single

So I have 6 separate automations total. I plan to condense them into 1 huge automation using trigger ids, but haven’t gotten around to it yet.

Also 1 big limitation, it doesn’t sync when alarmo is in it’s exit delay state, so you can not disarm the system using the keypad while alarmo is in it’s exit delay state, you have to wait till alarmo sets the system to armed or disarm using alarmo card on your phone. For me this is no big deal because I never manually set my alarm to armed away, it auto arms when my wife and i both leave our apartment complex zone(yet another automation).

Hopefully some of this was helpful, it took a few hours to get the automations all typed up and tested, but I haven’t touched it since setting them up a few weeks ago and had no issues.

If anyone has any suggestions or improvements I would love to hear them!

This is very helpful, thanks! Just curious if the keypads tones work, for example, with entry delay. Also, I assume it’s possible to use the keypads as a chime for sensor opening as well?

The keypad makes tones when pressing buttons or if it is armed/disarmed by the automation. But it does not make tones when entry delay is started or anything like that. There is also no way to control or trigger it to make noise with ZHA right now. None of the other sensors work, including the battery indicator. If you manage to get any of that working with ZHA please let me know!

I have a script that announces the entry delay and when it’s disarmed etc. I use my Google home speakers and TTS to make the announcements.

I’m stuck a bit here. I managed to get my keypads added to ZHA but am not sure where to go from here to get it working with Alarmo. How do I get the keypad connected so that it sends the signal code to Alarmo? Sorry for the newbie question!

You actually can’t send different codes from the keypad to alarmo. You can only arm and disarm using 1 code for the keypad. You set the keypad code in ZHA settings. Then You have 2 alarm entitys, the keypad alarm and alarmo. What you do then is use automations or this script to sync the 2 alarm panels so they are always the same state.
It took me a while to wrap my head around it, it’s not super intuitive.

You actually can: 4 Automations For A Better Smart Home Alarm System!

Has anybody had any experience with the Link2Home keypad and managed to get it working with Home Assistant / ALARMO?