Zigbee2MQTT - Sync Keypad and Alarm Control Panel States

All looks fine to me. Here’s the blueprint config (having removed the 4 digit pin):

id: ‘1641850868060’
alias: ‘Alarm #15: Hive keypad sync’
description: ‘’
use_blueprint:
path: AndrejDelany/zigbee2mqtt-sync-keypad-and-alarm-control-panel-states.yaml
input:
z2m_keypad_path: zigbee2mqtt/HiveKeypad
z2m_keypad_path_set: zigbee2mqtt/HiveKeypad/set
pin: ‘’
control_panel: alarm_control_panel.home
action_arming: []
action_panic:
- service: notify.all_mobile_devices
data:
title: Hive Keypad SOS button pressed
message: The SOS button has been pressed on the Hive Keypad.
data:
ttl: 0
priority: high

Problem within HA has been resolved today - upgrading to 2021.12.9 has resulted in my Hive keypad working as intended. Thank you again for this blueprint, Stefan!

Thank you for sharing!

I finally got it working installation the Edge version of Zigbee2MQTT.

I’m not so familiar with HA blueprints/scripts but do you think that it could be possible to the access to the alarmo username/password to decide whenever a pin is valid or not.

I had a look at your Blueprint code and it should be possible IF we can get the alarmo credentials.
Do you think this is possible? (did not find them)

Have a great day.
Thomas

Actually, I’m not using alarmo and am not familiar with it. But if you like to contribute to this blueprint, this is always welcome :slight_smile:

1 Like

Hello, I have tried something by myself, not tested it intensively yet, but I share it already.

blueprint:
  name: PIN-Keypads for Zigbee2MQTT
  description: "This Blueprint allows the synchronisation of an alarm control panel with a Zigbee2MQTT keypad. This means that the status of the alarm control panel is transmitted to the keypad and vice versa."
  domain: automation
  input:
    z2m_keypad_path:
        name: MQTT State Topic of your Zigbee2MQTT Keypad
        description: "The State Topic is composed of your Zigbee2MQTT base_topic (see your Z2M Addon Configuration) and the Friendly Name of your keypad in Z2M. Example: zigbee2mqtt/Keypad"
    z2m_keypad_path_set:
        name: MQTT Set Topic of your Zigbee2MQTT Keypad
        description: "This is the same as your State Topic, with the addition of /set. Example: zigbee2mqtt/Keypad/set"
    pin:
        name: Pincode
        description: "The valid pin code to be accepted as correct by your alarm system. Example: 1234"
    control_panel:
        name: Control Panel
        description: "An alarm control panel. Example: https://www.home-assistant.io/integrations/manual"
        default: []
        selector:
            entity:
                domain: alarm_control_panel
    action_arming:
        name: Action Arming
        description: "An action to be performed when the alarm panel changes to the arming state."
        default: []
        selector:
            action: {}
    action_armed_home:
        name: Action Armed Home
        description: "An action to be performed when the alarm panel changes to the armed home state."
        default: []
        selector:
            action: {}
    action_armed_night:
        name: Action Armed Night
        description: "An action to be performed when the alarm panel changes to the armed night state."
        default: []
        selector:
            action: {}
    action_armed_away:
        name: Action Armed Away
        description: "An action to be performed when the alarm panel changes to the armed away state."
        default: []
        selector:
            action: {}
    action_disarmed:
        name: Action Disarmed
        description: "An action to be performed when the alarm panel changes to the disarmed state."
        default: []
        selector:
            action: {}
    action_pending:
        name: Action Pending
        description: "An action to be performed when the alarm panel changes to the pending state."
        default: []
        selector:
            action: {}
    action_panic:
        name: Action Panic
        description: "An action to be performed when the panic / SOS button of the keypad is pressed."
        default: []
        selector:
            action: {}

variables:
  pin_var: !input 'pin'

trigger:
  - platform: state
    entity_id: !input 'control_panel'
    to: arming
    id: panel_arming
  - platform: state
    entity_id: !input 'control_panel'
    to: armed_home
    id: panel_armed_home
  - platform: state
    entity_id: !input 'control_panel'
    to: armed_night
    id: panel_armed_night
  - platform: state
    entity_id: !input 'control_panel'
    to: disarmed
    id: panel_disarmed
  - platform: state
    entity_id: !input 'control_panel'
    to: armed_away
    id: panel_armed_away
  - platform: state
    entity_id: !input 'control_panel'
    to: pending
    id: panel_pending
  - platform: mqtt
    topic: !input z2m_keypad_path
    id: keypad_mqtt
      
condition: []
    
action:
  - choose:
      - conditions:
          - condition: trigger
            id: panel_arming
        sequence:
          - choose:
              - conditions:
                  - condition: state
                    entity_id: !input 'control_panel'
                    state: armed_home
                    attribute: next_state
                sequence:
                  - service: mqtt.publish
                    data_template:
                      topic: !input 'z2m_keypad_path_set'
                      payload: |-
                        {
                         "arm_mode": 
                          {
                           "mode": "arm_day_zones"
                          }
                        }
              - conditions:
                  - condition: state
                    entity_id: !input 'control_panel'
                    state: armed_night
                    attribute: next_state
                sequence:
                  - service: mqtt.publish
                    data_template:
                      topic: !input 'z2m_keypad_path_set'
                      payload: |-
                        {
                         "arm_mode": 
                          {
                           "mode": "arm_night_zones"
                          }
                        }                        
              - conditions:
                  - condition: state
                    entity_id: !input 'control_panel'
                    state: armed_away
                    attribute: next_state
                sequence:
                  - service: mqtt.publish
                    data_template:
                      topic: !input 'z2m_keypad_path_set'
                      payload: |-
                        {
                         "arm_mode": 
                          {
                           "mode": "exit_delay"
                          }
                        }
            default: []
          - choose:
            default: !input 'action_arming'
      - conditions:
          - condition: trigger
            id: panel_armed_away
        sequence:
          - service: mqtt.publish
            data_template:
              topic: !input 'z2m_keypad_path_set'
              payload: |-
                {
                 "arm_mode": 
                  {
                   "mode": "arm_all_zones"
                  }
                }
          - choose:
            default: !input 'action_armed_away'
      - conditions:
          - condition: trigger
            id: panel_armed_night
        sequence:
          - service: mqtt.publish
            data_template:
              topic: !input 'z2m_keypad_path_set'
              payload: |-
                {
                 "arm_mode": 
                  {
                   "mode": "arm_night_zones"
                  }
                }
          - choose:
            default: !input 'action_armed_away'
      - conditions:
          - condition: trigger
            id: panel_disarmed
        sequence:
          - service: mqtt.publish
            data_template:
              topic: !input 'z2m_keypad_path_set'
              payload: |-
                {
                 "arm_mode": 
                  {
                    "mode": "disarm"
                  }
                }
          - choose:
            default: !input 'action_disarmed'
      - conditions:
          - condition: trigger
            id: panel_armed_home
        sequence:
          - service: mqtt.publish
            data_template:
              topic: !input 'z2m_keypad_path_set'
              payload: |-
                {
                 "arm_mode": 
                  {
                   "mode": "arm_day_zones"
                  }
                }
          - choose:
            default: !input 'action_armed_home'
      - conditions:
          - condition: trigger
            id: panel_pending
        sequence:
          - choose:
            default: !input 'action_pending'
      - conditions:
          - condition: trigger
            id: keypad_mqtt
        sequence:
          - choose:
              - conditions:
                  - condition: template
                    value_template: >-
                      {{ trigger.payload_json.action_transaction != null and
                      trigger.payload_json.action_code == pin_var }}
                sequence:
                  - service: mqtt.publish
                    data_template:
                      topic: !input 'z2m_keypad_path_set'
                      payload: |-
                        {
                         "arm_mode": 
                          {
                            "transaction": "{{ trigger.payload_json.action_transaction }}",
                            "mode": "{{ trigger.payload_json.action }}"
                          }
                        }
          - choose:
              - conditions:
                  - condition: template
                    value_template: >-
                      {{ trigger.payload_json.action_code == pin_var and
                      trigger.payload_json.action == "arm_all_zones" }}
                sequence:
                  - service: alarm_control_panel.alarm_arm_away
                    target:
                      entity_id: !input 'control_panel'
                    data:
                      code: !input 'pin'
              - conditions:
                  - condition: template
                    value_template: >-
                      {{ trigger.payload_json.action_code == pin_var and
                      trigger.payload_json.action == "arm_day_zones" }}
                sequence:
                  - service: alarm_control_panel.alarm_arm_home
                    target:
                      entity_id: !input 'control_panel'
                    data:
                      code: !input 'pin'
              - conditions:
                  - condition: template
                    value_template: >-
                      {{ trigger.payload_json.action_code == pin_var and
                      trigger.payload_json.action == "arm_night_zones" }}
                sequence:
                  - service: alarm_control_panel.alarm_arm_night
                    target:
                      entity_id: !input 'control_panel'
                    data:
                      code: !input 'pin'
              - conditions:
                  - condition: template
                    value_template: >-
                      {{ trigger.payload_json.action_code == pin_var and
                      trigger.payload_json.action == "disarm" }}
                sequence:
                  - service: alarm_control_panel.alarm_disarm
                    target:
                      entity_id: !input 'control_panel'
                    data:
                      code: !input 'pin'
              - conditions:
                  - condition: template
                    value_template: >-
                      {{ trigger.payload_json.action == "panic" }}
                sequence:
                  - choose:
                    default: !input 'action_panic'
              - conditions:
                  - condition: template
                    value_template: >-
                      {{ trigger.payload_json.action_code != pin_var and
                      trigger.payload_json.action_code | int(-1) != -1 }}
                sequence:
                  - service: mqtt.publish
                    data_template:
                      topic: !input 'z2m_keypad_path_set'
                      payload: |-
                        {
                         "arm_mode": 
                          {
                           "transaction": "{{ trigger.payload_json.action_transaction }}",
                           "mode": "invalid_code"
                          }
                        }
              - conditions:
                  - condition: template
                    value_template: >-
                      {{ trigger.payload_json.action == None }}
                sequence:
                  - choose:
                      - conditions:
                          - condition: state
                            entity_id: !input 'control_panel'
                            state: armed_away
                        sequence:
                          - service: mqtt.publish
                            data_template:
                              topic: !input 'z2m_keypad_path_set'
                              payload: |-
                                {
                                 "arm_mode": 
                                  {
                                   "mode": "arm_all_zones"
                                  }
                                }
                      - conditions:
                          - condition: state
                            entity_id: !input 'control_panel'
                            state: armed_home
                        sequence:
                          - service: mqtt.publish
                            data_template:
                              topic: !input 'z2m_keypad_path_set'
                              payload: |-
                                {
                                 "arm_mode": 
                                  {
                                   "mode": "arm_day_zones"
                                  }
                                }
                      - conditions:
                          - condition: state
                            entity_id: !input 'control_panel'
                            state: armed_night
                        sequence:
                          - service: mqtt.publish
                            data_template:
                              topic: !input 'z2m_keypad_path_set'
                              payload: |-
                                {
                                 "arm_mode": 
                                  {
                                   "mode": "arm_night_zones"
                                  }
                                }
                      - conditions:
                          - condition: state
                            entity_id: !input 'control_panel'
                            state: disarmed
                        sequence:
                          - service: mqtt.publish
                            data_template:
                              topic: !input 'z2m_keypad_path_set'
                              payload: |-
                                {
                                 "arm_mode": 
                                  {
                                   "mode": "disarm"
                                  }
                                }
                      - conditions:
                          - condition: state
                            entity_id: !input 'control_panel'
                            state: arming
                          - condition: state
                            entity_id: !input 'control_panel'
                            state: armed_home
                            attribute: next_state
                        sequence:
                          - service: mqtt.publish
                            data_template:
                              topic: !input 'z2m_keypad_path_set'
                              payload: |-
                                {
                                 "arm_mode": 
                                  {
                                   "mode": "arm_day_zones"
                                  }
                                }
                      - conditions:
                          - condition: state
                            entity_id: !input 'control_panel'
                            state: arming
                          - condition: state
                            entity_id: !input 'control_panel'
                            state: armed_away
                            attribute: next_state
                        sequence:
                          - service: mqtt.publish
                            data_template:
                              topic: !input 'z2m_keypad_path_set'
                              payload: |-
                                {
                                 "arm_mode": 
                                  {
                                   "mode": "arm_all_zones"
                                  }
                                }
            default: []
    default: []
      

mode: parallel
max: 10        
1 Like

I am familiar with Alarmo.
I’m afraid stored codes cannot be read from Alarmo, since they are stored encrypted.
My suggestion would be to store the code in the secrets file and use that for this blueprint (I suppose it can handle secrets?)
Alarmo cannot read secrets (yet?) so you would have to store the same code there as well.

Thank you for your feedback.

Then I will try to adapt the Blueprint (or write a new one from Scratch) to use the Alarmo MQTT commands that support PIN codes:

I will let you know (no so much time at the moment…)

I think that is not a good idea. MQTT is intended for communication from HA to another system (such as zigbee2mqtt), for internal communication we can use services.
Alarmo supports standard services such as alarm_control_panel.alarm_arm_away etc. which can be used to send the pin code as well. So I think no changes are needed in your bleprint, it’s already compatible.

I think the question from @titom43 was about an option to not have to enter the code in this blueprint and in Alarmo configuration. I think this is currently not possible.

OK. Got it!

I will then try to use services…

IMHO, the code can be forwarded to the service (or MQTT) and wait for the answer to reply to the keyboard.
Don’t you think?

BTW, did not see that you were THE “Niels” from Alarmo.

So what do you think is the best way to integrate Keypads to “your” Alarmo system?
(duplicating the PIN codes is not a good idea… also the pre/post commands that should be handled by Alarmo)

Thank you in advance for your expert opinion

Hi again :slight_smile:

I’ve got it working with your blueprint and a Linkind keypad.

Also it’s working with Alarmo, but it’s really quick & dirty.
More dirty then quick I suppose.

I’ve configured two persons with two individual codes in Alarmo.
With the blueprint I’ve created two automations. The actions in the blueprint call services from Alarmo with the pincode from the person. So the same pincode is set within the automation.
The dirty part is that you need a automation for every person AND the code is readable in the yaml file. But… it works!

Great piece, just orders a linkind keypad. Also watching this post and blueprint
Synchronize Ring Alarm Keypad v2 with Alarmo
Seems like between these there is a way to use this keypad with alarmo and setting codes.

Nice looking blueprint here and can almost replace a couple of different automations I already have setup for Alarmo and a keypad. However I don’t like the idea of saving the pin in the automation or having to create multiple automations if you have more than 1 code.
Isn’t it easier to have Alarmo do the pin verification instead of comparing that in the automation itself meaning you can leave the pin out of the automation entirely?

Something like this:

action:
  - service: alarm_control_panel.alarm_disarm
    target:
      entity_id:
        - alarm_control_panel.alarmo
    data_template:
      code: '{{trigger.payload_json["action_code"]}}'
2 Likes

Hoping the same!

Where can i buy the linkind keypad ? Cant find it on any store

I’ve got a problem, just bought one, synching with zigbee2mqtt fine, but leave it overnight and in the morning it fails to connect, as in red light on keypad, yet zigbee2mqtt shows messages received fine. Remove battery and it’ll work again. I’ve got some debug logs. Is it due to the response is all nulls? Happened two days in a trot.

I found it at Amazon

Maybe you can post a issue at zigbee2mqtt GitHub because it doesn’t seem it’s HA related.

OK but it looks like the automation is not sending a response back just as described in your instructions " * A successfully paired keypad in Zigbee2MQTT. Don’t panic if the keypads connection LED is still blinking. This is no issue and will be solved later."

i bought the linkind keypad but cant get it to work with z2m any ideas ?
the interview seems to fail.

Log:

Warning Received message from unsupported device with Zigbee model 'ZB-KeypadGeneric-D0002' and manufacturer name 'lk' Warning Please see: https://www.zigbee2mqtt.io/how_tos/how_to_support_new_devices.html. 
Warning Received message from unsupported device with Zigbee model 'ZB-KeypadGeneric-D0002' and manufacturer name 'lk' 
Warning Please see: https://www.zigbee2mqtt.io/how_tos/how_to_support_new_devices.html.
 Warning Received message from unsupported device with Zigbee model 'ZB-KeypadGeneric-D0002' and manufacturer name 'lk' 
Warning Please see: https://www.zigbee2mqtt.io/how_tos/how_to_support_new_devices.html.

it also get shown as unsupported.

i have tryed to resett it several times
any suggestions ?