Automation to syncronize a Zigbee Xfinity Keypad/PIN Pad (ZHA) and Alarmo

Hi all,

I bought a used Zibee Xfinity Keypad/PIN Pad and wanted to use it with Alarmo. I found a few solutions when you are using Zigbee2MQTT but I use ZHA, so I wrote an automation that would sync the Keypad and Alarmo using Alarmo built-in MQTT capabilities.

Pre-requisites:

  • Alarmo Custom Integrations installed and configured:
    • MQTT Enabled and configured to require a code
    • Armed away, Armed home, and Armed night Modes configured
    • A Pincode configured
  • Mosquito broker installed and configured
  • An Zigbee Xfinity XHK1-UE (I bought a second hand one at eBay) configured in ZHA
    • In ZHA configuration, set the Master code for the alarm control painel to 00000 and the number of consecutive failed code entries to trigger an alarm to 1000 (the automation is not using this feature)
  • An correctly configured notify service

What the automation does:

  • Enable you to use the Keypad to Arm and Disarm Alarmo using the codes configured in Alarmo
  • Enable Alarmo to sync its state with the Keypad
  • Send notifications when the Alarm is Armed, Disarmed or is Arming, and when an invalid password is used or the Alarm failed to arm because a sensor was triggered.

The automation:
IMPORTANT: Replace <replace me for your Keypad ieee>, <replace me for your Keypad device_id> for your device IEEE and device_id, and set the keypad Master code for the alarm control painel to 00000

alias: "Alarmo - ZHA Xfinity Keypad and Alarmo Syncronization "
description: >-
  This automation will integrate a Xfinity xhk1-ue ZigBee Wireless Keypad  from
  Comcast with Alarmo HACS addon. It allows you to arm and disarms Alarmo via the
  keypad using the Alarmo passwords and not the Keypad password configured in
  ZHA. It will also sync the keypad state with Alarmo.
trigger:
  - platform: event
    event_type: zha_event
    event_data:
      device_ieee: <replace me for your Keypad ieee>
      args:
        arm_mode_description: Disarm
    id: disarm
  - platform: event
    event_type: zha_event
    event_data:
      device_ieee: <replace me for your Keypad ieee>
      args:
        arm_mode_description: Arm_Day_Home_Only
    id: arm_home
  - platform: event
    event_type: zha_event
    event_data:
      device_ieee: <replace me for your Keypad ieee>
      args:
        arm_mode_description: Arm_All_Zones
    id: arm_away
  - platform: event
    event_type: zha_event
    event_data:
      device_ieee: <replace me for your Keypad ieee>
      args:
        arm_mode_description: Arm_Night_Sleep_Only
    id: arm_night
  - platform: mqtt
    topic: alarmo/state
    id: alarmo_state_disarmed
    payload: disarmed
  - platform: mqtt
    topic: alarmo/state
    id: alarmo_state_armed_home
    payload: armed_home
  - platform: mqtt
    topic: alarmo/state
    id: alarmo_state_armed_away
    payload: armed_away
  - platform: mqtt
    topic: alarmo/state
    id: alarmo_state_armed_night
    payload: armed_night
  - platform: mqtt
    topic: alarmo/state
    id: alarmo_state_armed_arming
    payload: arming
  - platform: mqtt
    topic: alarmo/event
    id: alarmo_state_invalid_code
    payload: INVALID_CODE_PROVIDED
    value_template: "{{ value_json.event }}"
  - platform: mqtt
    topic: alarmo/event
    id: alarmo_failed_to_arm
    payload: FAILED_TO_ARM
    value_template: "{{ value_json.event }}"
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: disarm
        sequence:
          - service: mqtt.publish
            data:
              topic: alarmo/command
              payload_template: >-
                { "command": "DISARM", "code": "{{ trigger.event.data.args.code
                }}" }
      - conditions:
          - condition: trigger
            id: arm_home
        sequence:
          - service: mqtt.publish
            data:
              topic: alarmo/command
              payload_template: >-
                { "command": "ARM_HOME", "code": "{{
                trigger.event.data.args.code }}" }
      - conditions:
          - condition: trigger
            id: arm_away
        sequence:
          - service: mqtt.publish
            data:
              topic: alarmo/command
              payload_template: >-
                { "command": "ARM_AWAY", "code": "{{
                trigger.event.data.args.code }}" }
      - conditions:
          - condition: trigger
            id: arm_night
        sequence:
          - service: mqtt.publish
            data:
              topic: alarmo/command
              payload_template: >-
                { "command": "ARM_NIGHT", "code": "{{
                trigger.event.data.args.code }}" }
    default: []
  - choose:
      - conditions:
          - condition: trigger
            id: alarmo_state_disarmed
          - condition: not
            conditions:
              - condition: device
                device_id: <replace me for your Keypad device_id>
                domain: alarm_control_panel
                entity_id: alarm_control_panel.front_door_alarm_pinpad_alarmcontrolpanel
                type: is_disarmed
        sequence:
          - device_id: <replace me for your Keypad device_id>
            domain: alarm_control_panel
            entity_id: alarm_control_panel.front_door_alarm_pinpad_alarmcontrolpanel
            type: disarm
            code: "00000"
          - service: notify.notify
            data:
              message: clear_notification
              data:
                tag: alarmo
          - service: notify.notify
            data:
              title: Alarmo
              message: Home alarm Disarmed.
              data:
                tag: alarmo
      - conditions:
          - condition: trigger
            id: alarmo_state_armed_home
        sequence:
          - device_id: <replace me for your Keypad device_id>
            domain: alarm_control_panel
            entity_id: alarm_control_panel.front_door_alarm_pinpad_alarmcontrolpanel
            type: arm_home
            code: "00000"
          - service: notify.notify
            data:
              message: clear_notification
              data:
                tag: alarmo
          - service: notify.notify
            data:
              title: Alarmo
              message: Home alarm Armed Home.
              data:
                tag: alarmo
      - conditions:
          - condition: trigger
            id: alarmo_state_armed_away
        sequence:
          - device_id: <replace me for your Keypad device_id>
            domain: alarm_control_panel
            entity_id: alarm_control_panel.front_door_alarm_pinpad_alarmcontrolpanel
            type: arm_away
            code: "00000"
          - service: notify.notify
            data:
              message: clear_notification
              data:
                tag: alarmo
          - service: notify.notify
            data:
              title: Alarmo
              message: Home alarm Armed Away.
              data:
                tag: alarmo
      - conditions:
          - condition: trigger
            id: alarmo_state_armed_night
        sequence:
          - device_id: <replace me for your Keypad device_id>
            domain: alarm_control_panel
            entity_id: alarm_control_panel.front_door_alarm_pinpad_alarmcontrolpanel
            type: arm_night
            code: "00000"
          - service: notify.notify
            data:
              message: clear_notification
              data:
                tag: alarmo
          - service: notify.notify
            data:
              title: Alarmo
              message: Home alarm Armed Night.
              data:
                tag: alarmo
      - conditions:
          - condition: trigger
            id: alarmo_state_armed_arming
        sequence:
          - service: notify.notify
            data:
              title: Alarmo
              message: Home alarm is arming.
              data:
                tag: alarmo
      - conditions:
          - condition: trigger
            id: alarmo_state_invalid_code
        sequence:
          - service: notify.notify
            data:
              title: Alarmo
              message: An invalid code was used to arm or disarm the Home Alarm.
              data:
                tag: alarmo
      - conditions:
          - condition: trigger
            id: alarmo_failed_to_arm
        sequence:
          - service: notify.notify
            data:
              title: Alarmo
              message: >-
                Home Alarm failed to arm because of the following sensors: {%
                for open_sensor in trigger.payload_json.sensors %}
                  {{ open_sensor.name }}
                {% endfor %}
              data:
                tag: alarmo
    default: []
mode: parallel
max: 2
8 Likes

This is working for me to arm/disarm the alarm but the keypad itself always shows armed. Is there something I may be missing? I’ve checked that I’ve followed the instructions a half dozen times.

Nevermind, I got it. Needed to update the entity IDs for the alarm control panel.

Could this work with other keypads in ZHA? I have the Hive keypad KEYPAD001 and am currently using Alarmo and was thinking of integrating both.

It should be possible if the Zigbee Keypad is generating zha_event.

You need to go to Developer Tools → Events and start listening for zha_event

Have some fun arming and disarming your keypad and see what events it is spitting out.

1 Like

Hi.
Any luck with this. Looking for a UK option and wondering if you managed to get this to work
Thank you

Yes this automation worked with the Hive keypad!

Anyone find a way to update the color status of the keypad — red for armed, green for disarmed?

Ever find it?

Hi Can anyone help me with this . I have the Hive Keypad ZHA. But its not talking to alarmo. I think I have done everything it says me to do

Hi. Did you get this working with Hive Keypad ?

Thanks

Yes! I had to turn on MQTT in Alarmo

Yes I have turned this on … Did you need to change anything else in the code