Aqara Wireless Switch WXKG12LM (via Zigbee2MQTT device trigger)

This blueprint exposes WXKG12LM actions via a device trigger, required in the upcoming Zigbee2MQTT 2.0 release.

Edit: This was reverted in fix(ignore): Add back Home Assistant legacy action sensor by Koenkk · Pull Request #25192 · Koenkk/zigbee2mqtt · GitHub and the sensor entities have been restored. Of course, this blueprint still works, but users upgrading to the 2.0 release when it’s out won’t have any breaking automations to fix up.

This is nearly identical to Aqara Wireless Switch WXKG11LM (via Zigbee2MQTT device trigger), but a separate blueprint because the newer switch does not support triple and quadruple clicks in favour of a gyroscope.

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

blueprint:
  name: Aqara Wireless Switch WXKG12LM (via Zigbee2MQTT device trigger)
  description: Control anything using Aqara Wireless Switch
  domain: automation
  input:
    device:
      name: Switch
      description: Aqara Wireless Switch to use
      selector:
        device:
          filter:
            - manufacturer: Aqara
              model: Wireless mini switch (with gyroscope) (WXKG12LM)
            - manufacturer: Aqara
              model: Wireless mini switch (with gyroscope)
          multiple: false
    press_single:
      name: Single button press
      description: Action to run on single button press
      default: []
      selector:
        action: {}
    press_double:
      name: Double button press
      description: Action to run on double button press
      default: []
      selector:
        action: {}
    press_hold:
      name: Hold button press
      description: Action to run on button hold
      default: []
      selector:
        action: {}
    press_release:
      name: Release button
      description: Action to run when button is released
      default: []
      selector:
        action: {}
    press_shake:
      name: Shake switch
      description: Action to run on shaking the switch
      default: []
      selector:
        action: {}
  source_url: https://community.home-assistant.io/t/aqara-wireless-switch-wxkg11lm-via-zigbee2mqtt-device-trigger/808126
mode: queued
max_exceeded: silent
trigger:
  - platform: device
    domain: mqtt
    device_id: !input device
    type: action
    subtype: single
  - platform: device
    domain: mqtt
    device_id: !input device
    type: action
    subtype: double
  - platform: device
    domain: mqtt
    device_id: !input device
    type: action
    subtype: hold
  - platform: device
    domain: mqtt
    device_id: !input device
    type: action
    subtype: release
  - platform: device
    domain: mqtt
    device_id: !input device
    type: action
    subtype: shake
action:
  - choose:
      - conditions: "{{ trigger.payload == 'single' }}"
        sequence: !input press_single
      - conditions: "{{ trigger.payload == 'double' }}"
        sequence: !input press_double
      - conditions: "{{ trigger.payload == 'hold' }}"
        sequence: !input press_hold
      - conditions: "{{ trigger.payload == 'release' }}"
        sequence: !input press_release
      - conditions: "{{ trigger.payload == 'shake' }}"
        sequence: !input press_shake

While trying to import, I get the following error, “mapping values are not allowed here in “”, line 2, column 14: description: Control anything using Aqara W … ^”

Try now! I mispasted before and missed the blueprint: line.

Done.
EZPZ
Thank you!

I’m not able to get this blueprint to work with my switch. It was working fine before the 2.0 update and was able to restore double switch remote I have.
But when I import this blueprint and create an automation the wireless switch doesn’t pop up in the list.

I do see it states and is updating to whatever command I do on that thing

But here it doesn’t find anything. Even when I use the entity what you can see on the other screenshot it doesn’t let me save it anyway.

Inside blueprint there is a filter for

model: Wireless mini switch (with gyroscope) (WXKG12LM)

But in your (and my) case the model is

model: Wireless mini switch (with gyroscope)

If you edit the blueprint filter it will pop up.

1 Like

Aah thx, got it.

Nice! I’m not sure why mine is different. I did set the button up a few years ago, so perhaps the default names changed at one point in zigbee2mqtt? Either way, I’ve updated the blueprint to accept both formats.

1 Like