ZHA - Xiaomi Aqara Wireless Mini Switch (WXKG11LM) - lumi.sensor_switch.aq2

Introduction:

This Blueprint allows you to configure an Xiaomi Aqara Wireless Mini Switch (WXKG11LM) paired to the ZHA integration. The Zigbee ID for this button is “lumi.sensor_switch.aq2”.

It supports five commands - single press, double press, triple press, quadruple press and “multiple” press, which is basically anything higher than 5 presses.

Note: I think that the >5 presses action was not intended to be used like this, but it just works! When you press the button 5 or more times, you’ll even see the blue “pairing light” blink, and the button sends his identification", but i have been using it for automations and so, and since it works, you can also use it! If you don’t feel like it, leave the multiple presses blank :slight_smile:

This blueprint is based on ZHA - Aqara Wireless Mini Switch from @SeanM!

As @SeanM mentions on his blueprint:

Also, an additional tip: if you select the “Choose” action type, you can increase the amount of actions each button is capable of executing. For example you can make “double press” activate a scene by default, but make it skip tracks if Spotify is playing, and make it fast forward if you’re watching a movie.

Other Recommended Xiaomi ZHA Blueprints:

Here are some Blueprints I am using for Xiaomi devices using ZHA, which are working great.

ZHA - Xiaomi Mijia Round Wireless Switch (WXKG01LM) - lumi.sensor_switch - by me, @carlosmesquita
ZHA - Aqara Wireless Remote Switch (Double Rocker) - by @NachtaktiverHalbaffe

Requirements

Blueprint

Click the badge to import this Blueprint: (needs Home Assistant Core 2021.3 or higher)

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

Or import this Blueprint by using the forum topic URL:

blueprint:
  name: ZHA - Xiaomi Aqara Wireless Mini Switch (WXKG11LM)
  description: Automate your Xiaomi Aqara Wireless Mini Remote Switch using ZHA events.
  domain: automation
  input:
    mijia_square_switch:
      name: Aqara Wireless Square Switch
      description: Aqara Wireless Square Switch to use
      selector:
        device:
          integration: zha
          manufacturer: LUMI
          model: lumi.sensor_switch.aq2
    remote_button_short_press:
      name: Single Press
      description: Action to run on single press
      default: []
      selector:
        action: {}
    remote_button_double_press:
      name: Double Press
      description: Action to run on double press
      default: []
      selector:
        action: {}
    remote_button_triple_press:
      name: Triple Press
      description: Action to run on triple press
      default: []
      selector:
        action: {}
    remote_button_quadruple_press:
      name: Quadruple Press
      description: Action to run on quadruple press
      default: []
      selector:
        action: {}
    remote_button_multiple_press:
      name: Multiple Press
      description: Action to run on multiple press
      default: []
      selector:
        action: {}
mode: parallel
max_exceeded: silent
trigger:
- platform: event
  event_type: zha_event
  event_data:
    device_id: !input 'mijia_square_switch'
action:
- variables:
    args_val: '{{ trigger.event.data.args.value }}'
- choose:
  - conditions:
    - "{{ trigger.event.data.args.value == 0 }}"
    sequence: !input 'remote_button_short_press'
  - conditions:
    - '{{ args_val == 2 }}'
    sequence: !input 'remote_button_double_press'
  - conditions:
    - '{{ args_val == 3 }}'
    sequence: !input 'remote_button_triple_press'
  - conditions:
    - '{{ args_val == 4 }}'
    sequence: !input 'remote_button_quadruple_press'
  - conditions:
    - '{{ args_val == ''lumi.sensor_switch.aq2'' }}'
    sequence: !input 'remote_button_multiple_press'

Notes:

  1. The condition for the single press are different from the other actions, because i had some issues while using the variable. You can check this out here: Blueprint | Issues with boolean variables handling

  2. The conditions for the multiple press is also different, and even more weird, because as i mention above, I think this event was not intended to be used as a “multiple press action”.

Below you can check the Automation creation screen from this blueprint:

Changelog

  • 2021-02-20: Changed Automation Mode from restart to parallel, to fix multiple actions per event not working properly.
  • 2020-12-20: Initial version.

Enjoy! :sunglasses:

5 Likes

Hi and thank you for sharing this.

I have the next version of this Aqara button (WXKG12LM) which is basically the same button but with and added “shake” feature. In HA it is registered as lumi.sensor_switch.aq3 (instead of lumi.sensor_switch.aq.2) and I was able to import it in your blueprint by changing the last digit.

However and as far as I know, these buttons support single, double and long press. In the UI these are the options you are getting:

And in the zha_event listener this are the values I am receiving:

"command": "single"
"command": "double"
"command": "hold"
"command": "release"

Are you sure that your button has the functionality you describe? I am pretty sure that the triple and quadruple clicks are supported in the 1st version of these Xiaomi buttons (WXKG01LM)

Hello @HawkMan!
Regarding the round buttons (WXKG01LM), i also made a Blueprint for that here, and in fact it supports triple/quad/multiple presses.

I have those buttons, and the WXKG11LM version of the square, which does not have a gyro, but does in fact support triple & quad presses, but also support multiple presses, which i explain in the first post (check the Notes section.

You can check in this site, by @blakadder, both buttons:

WXKG11LM
WXKG12LM

And you can see they are different, the version with gyro only supports single/double, hold/release & shake, and the version i own, doesn’t support hold/release, neither shake, but support different “multiple” presses. I have tested this BP with my buttons and it works fine :wink:

Wow, I didn’t know that the previous version (WXKG11LM) had all this button press functionality.

I remember that when researching for it, most of the time I was reading for the single, double and long press abilities and I thought that getting the WXKG12LM was a better deal (with the added shake function).

Seems I was wrong and someone in this post from the HA community was indeed reporting the single, double, triple and quadruple functions (although via zigbee2mqqt but I don’t think that matters). Others of course reported the other functions (single, double and long)

So from what it seems the WXKG11LM button is like a jackpot?

The shake function on the WXKG12LM is nice, but i like my WXKG11LM hehe

But the remotes i like the most are:

  1. The rounded ones (WXKG01LM), which support single/double/triple/quad/multiple/hold;
  2. The WXKG07LM and similar (there are versions with different number of buttons), which support single/double/hold on each button, and even combined (single press on both buttons, double, and hold on both), and they look great, feel great and have great pricing hehe

Hi Carlos,

From what it seems the 1st version of the Xiaomi buttons (WXKG01LM) are the best in terms of functionality. I could try and get the WXKG11LM but it seems that finding the ones that support the triple and quadruple presses is a bit hard.

The Aqara D1 (WXKG07LM) buttons indeed look great, I couldn’t resist and ordered a couple from AliExpress (as cheap as 12 Euros each!) to test them.

Thanks for sharing.

Hello!

Yes, the ones i like the most are the WXKG01LM… i just ordered two more recently :smiley:

Yes, they are crazy cheap for the product! Hope you like them :slight_smile:

Np!

I had to take out model as mine was named differance

my selector

      selector:
        device:
          integration: zha
          manufacturer: LUMI

Is it working? The Blueprint?
Because the way the events are sent might be different!

If it’s working, can you share your model? I can try to change the BP to include both models!

Thanks!

lumi.remote.b1acn01

@myle, there is actually a Blueprint specific to that model, check it out: ZHA - Aqara Wireless Mini Switch

Might be worth pointing out that the model number printed on the switch is identical, even though the internal identification code is different (I have the b1acn01 version, and it’s still labelled as a WXKG11LM on the device)

Yes, correct.
You can check this kind of stuff here: Aqara Wireless Mini Switch WXKG11LM Zigbee compatibility info
Props to @blakadder

Can this work with Matter? Thanks.

Hello All,

I am super new here. I am also super frustrated just trying to get this aqara mini switch to work. I am using the BETA Matter add-on and now a Zigbee dongle, so I am curious if that is why this method isn’t working.

See image:

I also tried to add an event automation, but for some reason, I do not see an event log what I try to listen to events on zha_event. Again, maybe this is just because I am using Matter. I see Dennis also asked the question, but just looking for some help. I’m a total newb, so I’m sure it is something I am just not understanding correctly, or doing correctly. Thanks! :slight_smile:

Hello @square and @bkhalterman,
The device might work with Matter, but this blueprint will only work for the ZHA integration, directly with Zigbee.

Beat regards

1 Like

I’ve got it working with Matter with the Aqara hub doing the Matter support. I have the version of this model that only supports a subset of these functions. This might be because I’m going through the Aqara hub. I’ll try a ZHA hookup later to see if indeed the events reach HA with function beyond the double press.

blueprint:
  name: Matter - Aqara Wireless Mini Switch
  description: Automate your Aqara Wireless Mini Switch when run via Matter (with long/short press differentiation)
  author: EFH52 (enhanced by AI)
  domain: automation
  input:
    target_switch:
      name: Aqara Wireless Mini Switch
      description: Target Aqara Wireless Mini Switch to monitor
      selector:
        entity:
          integration: matter
          domain: event
          device_class: button

    short_press_action:
      name: Short Press Action
      description: Action to take on a short press
      default: []
      selector:
        action: {}

    long_press_action:
      name: Long Press Action
      description: Action to take on a long press
      default: []
      selector:
        action: {}

    double_press_action:
      name: Double Press Action
      description: Action to take on a double press
      default: []
      selector:
        action: {}

    triple_press_action:
      name: Triple Press Action
      description: Action to take on a triple press
      default: []
      selector:
        action: {}

    quadruple_press_action:
      name: Quadruple Press Action
      description: Action to take on a quadruple press
      default: []
      selector:
        action: {}

mode: single
max_exceeded: silent

trigger:
  - platform: state
    entity_id: !input target_switch
    attribute: event_type

action:
  - service: persistent_notification.create
    data:
      title: "Aqara Mini Switch Debug"
      message: "Event triggered:  event_type={{ trigger.to_state.attributes.event_type }}"

  - choose:
      - conditions:
          - condition: template
            value_template: "{{ trigger.to_state.attributes.event_type == 'short_release' }}"
        sequence: !input short_press_action

      - conditions:
          - condition: template
            value_template: "{{ trigger.to_state.attributes.event_type == 'long_press' }}"
        sequence: !input long_press_action

      - conditions:
          - condition: template
            value_template: "{{ trigger.to_state.attributes.event_type == 'multi_press_complete' and trigger.to_state.attributes.totalNumberOfPressesCounted == 2 }}"
        sequence: !input double_press_action

      - conditions:
          - condition: template
            value_template: "{{ trigger.to_state.attributes.event_type == 'multi_press_complete' and trigger.to_state.attributes.totalNumberOfPressesCounted == 3 }}"
        sequence: !input triple_press_action

      - conditions:
          - condition: template
            value_template: "{{ trigger.to_state.attributes.event_type == 'multi_press_complete' and trigger.to_state.attributes.totalNumberOfPressesCounted == 4 }}"
        sequence: !input quadruple_press_action

Not sure if it was a recent HA update or what but this blueprint automation no longer triggers. I can see the button working in events but traces in the in the automation are not acknowledging anything

Same here. This and another button blueprint stopped working. Hope to find a fix soon.

I also noticed that my automations weren’t working, but I found a solution. In the variables trigger.event.data.args.value needs to be changed into trigger.event.data.args.attribute_value, both on line 53 and 56.

An updated complete blueprint also can be found on: ZHA-WXKG11LM-blueprint.yml · GitHub