Aqara Buttons All-In-One [Zigbee2MQTT]

:warning::warning::warning::warning::warning::warning::warning::warning::warning:

Use a new native method to bind any keys without bluprints.

I no longer use this blueprint and have no plans to support it.

:warning::warning::warning::warning::warning::warning::warning::warning::warning:

Hi there!

Here is all-in-one package for Aqara Switches and Buttons.

Supports: WXKG11LM, WXKG12LM, WXKG03LM, WXKG06LM, WXKG07LM, WXKG02LM, WXKG**LM, QBKG04LM, QBKG11LM, QBKG12LM, QBKG19LM, QBKG20LM, QBKG21LM, QBKG22LM, QBKG25LM, QBKG31LM, QBKG**LM etc…).
Does not supports Opple.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Some actions may be unsupported by your switch. Check the available actions of your device on zigbee2mqtt.io.

Troubleshooting

Make sure, that homeassistant legacy triggers is NOT disabled in your zigbee2mqtt config. This option is enabled by default in Z2M, but can be accidentally turned off via UI dashboard. This is important!

It is also recommended to set the legacy: false in device_options to disable unused and deprecated click sensor.

Your Z2M config in UI should look like this:

Or if you are using YAML:

2022-04-08_17-37-27

Blueprint:

blueprint:
  name: Aqara Buttons All-In-One [Zigbee2MQTT]
  description: |
   All-In-One package for Aqara Switches.
   Supports: WXKG11LM, WXKG12LM, WXKG03LM, WXKG06LM, WXKG07LM, WXKG02LM, QBKG03LM, QBKG04LM, QBKG11LM, QBKG12LM, QBKG21LM, QBKG22LM, QBKG25LM, etc..).
   Does not supports Opple.
   Some actions may be unsupported by your switch. Check the available actions of your device on zigbee2mqtt.io.
  domain: automation
  input:
    action_sensor:
      name: Action Sensor
      description: Zigbee2mqtt action sensor
      selector:
        entity:
          integration: mqtt
          domain: sensor
    single_action:
      name: Single Click
      description: Single click for devices with one button
      default: []
      selector:
        action: {}
    double_action:
      name: Double Click
      description: Double click for devices with one button
      default: []
      selector:
        action: {}    
    triple_action:
      name: Triple Click
      description: Triple click for devices with one button
      default: []
      selector:
        action: {}     
    quadruple_action:
      name: Quadruple Click
      description: Triple click for devices with one button
      default: []
      selector:
        action: {}       
    hold_action:
      name: Hold Action
      description: Hold action for devices with one button
      default: []
      selector:
        action: {}     
    release_action:
      name: Release Action
      description: Release action for devices with one button
      default: []
      selector:
        action: {}    
    shake_action:
      name: Shake Action
      description: Shake action for devices with one button
      default: []
      selector:
        action: {}
    single_left_action:
      name: Single Left Click
      description: Left click for devices with multiple buttons
      default: []
      selector:
        action: {}
    double_left_action:
      name: Double Left Click
      description: Double left click for devices with multiple buttons
      default: []
      selector:
        action: {}     
    triple_left_action:
      name: Triple Left Click
      description: Triple left click for devices with multiple buttons
      default: []
      selector:
        action: {}     
    hold_left_action:
      name: Hold Left Action
      description: Hold left action for devices with multiple buttons
      default: []
      selector:
        action: {}    
    release_left_action:
      name: Release Left Action
      description: Release left action for devices with multiple buttons
      default: []
      selector:
        action: {}
    single_center_action:
      name: Single Center Click
      description: Center click for devices with three buttons
      default: []
      selector:
        action: {}
    double_center_action:
      name: Double Center Click
      description: Double center click for devices with three buttons
      default: []
      selector:
        action: {}     
    triple_center_action:
      name: Triple Center Click
      description: Triple center click for devices with three buttons
      default: []
      selector:
        action: {}     
    hold_center_action:
      name: Hold Center Action
      description: Hold center action for devices with three buttons
      default: []
      selector:
        action: {}    
    release_center_action:
      name: Release Center Action
      description: Release center action for devices with three buttons
      default: []
      selector:
        action: {}      
    single_right_action:
      name: Single Right Click
      description: Right click for devices with multiple buttons
      default: []
      selector:
        action: {}
    double_right_action:
      name: Double Right Click
      description: Double right click for devices with multiple buttons
      default: []
      selector:
        action: {}     
    triple_right_action:
      name: Triple Right Click
      description: Triple right click for devices with multiple buttons
      default: []
      selector:
        action: {}     
    hold_right_action:
      name: Hold Right Action
      description: Hold right action for devices with multiple buttons
      default: []
      selector:
        action: {}    
    release_right_action:
      name: Release Right Action
      description: Release right action for devices with multiple buttons
      default: []
      selector:
        action: {}    
    single_both_action:
      name: Single Both Click
      description: Both click for devices with multiple buttons
      default: []
      selector:
        action: {}
    double_both_action:
      name: Double Both Click
      description: Double both click for devices with multiple buttons
      default: []
      selector:
        action: {}     
    triple_both_action:
      name: Triple Both Click
      description: Triple both click for devices with multiple buttons
      default: []
      selector:
        action: {}     
    hold_both_action:
      name: Hold Both Action
      description: Hold both action for devices with multiple buttons
      default: []
      selector:
        action: {}    
    release_both_action:
      name: Release Both Action
      description: Release both action for devices with multiple buttons
      default: []
      selector:
        action: {}               
mode: parallel
max_exceeded: silent
trigger:
  platform: state
  entity_id: !input 'action_sensor'
action:
- variables:
    command: '{{ trigger.to_state.attributes.action if trigger.to_state.state == "" else trigger.to_state.state }}'
- choose:
  - conditions: '{{ command == ''single'' }}'
    sequence: !input 'single_action'
  - conditions: '{{ command == ''double'' }}'
    sequence: !input 'double_action'
  - conditions: '{{ command == ''triple'' }}'
    sequence: !input 'triple_action'
  - conditions: '{{ command == ''quadruple'' }}'
    sequence: !input 'quadruple_action'
  - conditions: '{{ command == ''hold'' }}'
    sequence: !input 'hold_action'
  - conditions: '{{ command == ''release'' }}'
    sequence: !input 'release_action'
  - conditions: '{{ command == ''shake'' }}'
    sequence: !input 'shake_action'
  - conditions: '{{ command == ''single_left'' }}'
    sequence: !input 'single_left_action'
  - conditions: '{{ command == ''double_left'' }}'
    sequence: !input 'double_left_action'
  - conditions: '{{ command == ''triple_left'' }}'
    sequence: !input 'triple_left_action'    
  - conditions: '{{ command == ''hold_left'' }}'
    sequence: !input 'hold_left_action' 
  - conditions: '{{ command == ''release_left'' }}'
    sequence: !input 'release_left_action'
  - conditions: '{{ command == ''single_center'' }}'
    sequence: !input 'single_center_action'
  - conditions: '{{ command == ''double_center'' }}'
    sequence: !input 'double_center_action'
  - conditions: '{{ command == ''triple_center'' }}'
    sequence: !input 'triple_center_action'    
  - conditions: '{{ command == ''hold_center'' }}'
    sequence: !input 'hold_center_action' 
  - conditions: '{{ command == ''release_center'' }}'
    sequence: !input 'release_center_action'    
  - conditions: '{{ command == ''single_right'' }}'
    sequence: !input 'single_right_action'
  - conditions: '{{ command == ''double_right'' }}'
    sequence: !input 'double_right_action'
  - conditions: '{{ command == ''triple_right'' }}'
    sequence: !input 'triple_right_action'    
  - conditions: '{{ command == ''hold_right'' }}'
    sequence: !input 'hold_right_action' 
  - conditions: '{{ command == ''release_right'' }}'
    sequence: !input 'release_right_action'       
  - conditions: '{{ command == ''single_both'' }}'
    sequence: !input 'single_both_action'
  - conditions: '{{ command == ''double_both'' }}'
    sequence: !input 'double_both_action'
  - conditions: '{{ command == ''triple_both'' }}'
    sequence: !input 'triple_both_action'    
  - conditions: '{{ command == ''hold_both'' }}'
    sequence: !input 'hold_both_action' 
  - conditions: '{{ command == ''release_both'' }}'
    sequence: !input 'release_both_action'

Available actions:



17 Likes

This looks cool! Any pointers on what I should modify for this to work with ZHA?

2 Likes

Hey there!

This looks like an awesome blueprint for Aqara switches. There has been a lot of thought put into making such a comprehensive blueprint.

I’m really new to this but hope you could shed some light on this.

I’ve a QBKG25LM switch but I cant seem to trigger any automation using this blueprint.

I’ve tried including this in my zigbee2mqtt configuration.yaml file

  "advanced": {
    "log_level": "warn",
    "legacy_api": false,

and also tried including this in my devices.yaml file

'0x04cf8cdf3c8b799c':
  friendly_name: Bedroom Switch
  legacy: false

I’ve tried one or the other as well but I’m not sure why it is not able to trigger my automation. Currently I’ve set the automation to turn on a smart light when I click my right switch. However nothing happens.

alias: 'Aqara Buttons All-In-One [Zigbee2MQTT]'
description: ''
use_blueprint:
  path: Drafted/aqara-buttons-all-in-one-zigbee2mqtt.yaml
  input:
    action_sensor: sensor.bedroom_switch_action
    single_right_action:
      - type: turn_on
        device_id: 5ff21eb30a10568d41a9d2d3c5b4e76f
        entity_id: light.lifx_big_test_1
        domain: light
        brightness_pct: 100

I’ve got errors in my logs here:

Logger: homeassistant.components.automation.aqara_buttons_all_in_one_zigbee2mqtt
Source: components/automation/__init__.py:416
Integration: Automation (documentation, issues)
First occurred: April 13, 2021, 11:58:11 PM (4 occurrences)
Last logged: 12:17:15 AM

Error while executing automation automation.aqara_buttons_all_in_one_zigbee2mqtt: UndefinedError: 'trigger' is undefined

and here:

Logger: homeassistant.components.automation.aqara_buttons_all_in_one_zigbee2mqtt
Source: helpers/script.py:1156
Integration: Automation (documentation, issues)
First occurred: April 13, 2021, 11:58:11 PM (4 occurrences)
Last logged: 12:17:15 AM

Aqara Buttons All-In-One [Zigbee2MQTT]: Error executing script. Error rendering template for variables at pos 1: UndefinedError: 'trigger' is undefined

wonder some help can be rendered here :slight_smile:

Thanks!

@mynameisused make sure the sensor sensor.bedroom_switch_action actually exists.
And try configuring automation through the UI.

Hi thanks so much for reaching out :slight_smile: I did configure the automation through the UI in this manner.

Not sure what i’m missing :frowning:

sry split posting cos i wasn’t allowed to upload more than one image.

the exposes from zigbee2mqtt

@mynameisused look like zigbe2mqtt send undefined in action on click.
Can you check log of zigbee2mqtt when press a key?

I’m not sure if this is the right logs though…could you guide me to get the right logs if this isn’t the right log.

i get this though…theres no msg payload from the sensor.bedroom_switch_action when i toggle my center switch…

@mynameisused Open issue in z2m repo.

I have used this for a while, but it stopped working.
After some testing, I found the code of the blueprint works when I remove the attribute: action.
I have the entity sensor.name_action selected as action sensor. Maybe that’s why, it looks double.

hello, new to this… I found this blueprint and I though it was GREAT!

I have created an action, but nothing happen when I click the button… how can I fix it? how can I debug it?

@FiNaRWhich Which switch model are you using?

WXKG01LM - Xiaomi WXKG01LM control via MQTT | Zigbee2MQTT

@TFhdKi95ae8L hmm… which version of z2m and models of aqara switches you use?

not using AQARA, but XIAOMI

image

@FiNaR can u remove this line from blueprint and try again?

image

P.S. Blueprint should located in config/blueprints/automation/Drafted/aqara-buttons-all-in-one-zigbee2mqtt.yaml

@mynameisused can u try also?

@Drafted no luck :frowning:

it seems I cannot trigger the automation:

how can I debug? I can see the XIAOMI button in the dashboard so, it is connected…

@FiNaR delete automation, edit blueprint file (remove 1 line) in configurator, then create new automation using this blueprint, set action sensor of your switch and set singe click action, save and test it.
You can also see z2m logs, when press a key.

I did use this but stopped working with the 2021.4.5 update
Made manual automations and they work