Home Assistant for the Xiaomi Aqara double key wall switch blueprint

This is a Blueprint for Home Assistant for the Xiaomi Aqara double key wall switch using zigbee2mqtt.
Unlike in this Blueprint all actions can be configured freely.

As suggested in the documentation, the device has to be updated to the non legacy mode in zigbee2mqtt.

This can be done with the following by adding the line legacy: false in the zigbee2mqtt configuration file as described in the documentation.

blueprint:
  name: Aqara Double Key Switch
  description: 'Blueprint for Home Assistant for the Xiaomi Aqara double key wireless wall switch using zigbee2mqtt.'
  domain: automation
  input:
    switch:
      name: Switch
      description: Action sensor of Aqara Wireless Switch to use
      selector:
        entity:
          domain: sensor
          integration: mqtt

    press_single_left:
      name: Single left button press
      description: Action to run on single left button press
      default: []
      selector:
        action: {}

    press_double_left:
      name: Double left button press
      description: Action to run on double left button press
      default: []
      selector:
        action: {}

    press_hold_left:
      name: Hold left button
      description: Action to run on holding left button
      default: []
      selector:
        action: {}

    press_single_right:
      name: Single right button press
      description: Action to run on single right button press
      default: []
      selector:
        action: {}

    press_double_right:
      name: Double right button press
      description: Action to run on double right button press
      default: []
      selector:
        action: {}

    press_hold_right:
      name: Hold right button
      description: Action to run on holding right button
      default: []
      selector:
        action: {}

    press_single_both:
      name: Single both buttons press
      description: Action to run on single both button press
      default: []
      selector:
        action: {}

    press_double_both:
      name: Double both buttons press
      description: Action to run on double both button press
      default: []
      selector:
        action: {}

    press_hold_both:
      name: Hold both buttons
      description: Action to run on holding both buttons
      default: []
      selector:
        action: {}


mode: restart
max_exceeded: silent
trigger:
  - platform: state
    entity_id: !input switch
   
action:
  - variables:
      command: "{{ trigger.to_state.state }}"

  - choose:
      - conditions:
          - "{{ command == 'single_left' }}"
        sequence: !input press_single_left
      - conditions:
          - "{{ command == 'double_left' }}"
        sequence: !input press_double_left
      - conditions:
          - "{{ command == 'hold_left' }}"
        sequence: !input press_hold_left

      - conditions:
          - "{{ command == 'single_right' }}"
        sequence: !input press_single_right
      - conditions:
          - "{{ command == 'double_right' }}"
        sequence: !input press_double_right
      - conditions:
          - "{{ command == 'hold_right' }}"
        sequence: !input press_hold_right

      - conditions:
          - "{{ command == 'single_both' }}"
        sequence: !input press_single_both
      - conditions:
          - "{{ command == 'double_both' }}"
        sequence: !input press_double_both
      - conditions:
          - "{{ command == 'hold_both' }}"
        sequence: !input press_hold_both

Screenshot:

1 Like

Hey there,
This is my first post here since migrating Node-Red to Home Assistant. I’ve been trying to use your Blueprint with these switches with Zigbee2MQTT but they never trigger anything.
I have disabled legacy, and can use the actions in individual automations, But I was hoping to avoid having loads of automations per switch. Any ideas what might be causing the issue or how I can diagnose it please as I am a noob to HA?
Thanks. :slight_smile:

Same Problem for me, nothings triggers.
Did you find a solution to the problem?

I found and am using this blueprint instead which works perfectly:
https://my.home-assistant.io/redirect/blueprint_import/?blueprint_url=https%3A%2F%2Fgist.github.com%2Ffoglietti%2F74b45df0b0713347484c133a97fdb2f8