Z2M Aqara wireless remote double switch (WXKG02LM_rev2) Blueprint

Blueprint for Aqara remote wireless double switch WXKG02LM_rev2 working with Zigbee2MQTT 2.0.0-1.

blueprint:
  name: Aqara wireless remote switch (double rocker) WXKG02LM_rev2 (Zigbee MQTT Trigger)
  description: "Controller automation for executing any kind of action triggered by the provided Aqara WXKG02LM_rev2 switch. \n\n
    You can have different actions on single left press, double left press, hold left press, single right press and double right press, \n
    hold right press, single both press, double both press, hold both press \n\n
    Make sure to manually create a separate Text Helper per switch device and define its entity in the automation. It's used
    to store the last controller event to filter possible empty events."
  domain: automation
  input:
    mqtt_topic:
      name: MQTT Topic
      description: Topic of the Aqara WXKG02LM_rev2
      default: zigbee2mqtt/<device name>
    helper_last_controller_event:
      name: (Required) Helper - Last Controller Event
      description: Input Text used to store the last event fired by the controller.
        You will need to manually create a text input Helper entity for this.
      default: ''
      selector:
        entity:
          domain:
          - input_text
          multiple: false
    single_left:
      name: Single left button press
      description: Action to run
      default: []
      selector:
        action: {}
    double_left:
      name: Double left button press
      description: Action to run
      default: []
      selector:
        action: {}
    hold_left:
      name: Hold of left button
      description: Action to run
      default: []
      selector:
        action: {}
    single_right:
      name: Single right button press
      description: Action to run
      default: []
      selector:
        action: {}
    double_right:
      name: Double right button press
      description: Action to run
      default: []
      selector:
        action: {}
    hold_right:
      name: Hold of right button
      description: Action to run
      default: []
      selector:
        action: {}
    single_both:
      name: Single both buttons press
      description: Action to run
      default: []
      selector:
        action: {}
    double_both:
      name: Double both buttons press
      description: Action to run
      default: []
      selector:
        action: {}
    hold_both:
      name: Hold of both buttons
      description: Action to run
      default: []
      selector:
        action: {}
mode: queued
max_exceeded: silent
trigger:
- platform: mqtt
  topic: !input mqtt_topic
condition:
- condition: template
  value_template: '{{ trigger.payload_json.action != '''' }}'
action:
- variables:
    helper_last_controller_event: !input helper_last_controller_event
    command: '{{ trigger.payload_json.action }}'
    prev_command: '{{ states(helper_last_controller_event) }}'
- service: input_text.set_value
  data:
    entity_id: !input helper_last_controller_event
    value: '{{ command }}'
- choose:
  - conditions:
    - '{{ command == "single_left" }}'
    sequence: !input single_left
  - conditions:
    - '{{ command == "double_left" }}'
    sequence: !input double_left
  - conditions:
    - '{{ command == "hold_left" }}'
    sequence: !input hold_left
  - conditions:
    - '{{ command == "single_right" }}'
    sequence: !input single_right
  - conditions:
    - '{{ command == "double_right" }}'
    sequence: !input double_right
  - conditions:
    - '{{ command == "hold_right" }}'
    sequence: !input hold_right
  - conditions:
    - '{{ command == "single_both" }}'
    sequence: !input single_both
  - conditions:
    - '{{ command == "double_both" }}'
    sequence: !input double_both
  - conditions:
    - '{{ command == "hold_both" }}'
    sequence: !input hold_both

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

Link to Z2M Xiaomi Mi wireless switch (WXKG01LM) Blueprint

Hi Foglietti,

Really appreciate you updating this so quickly after the Z2M update broke it - thank you!
I’m trying to import the new blueprint but when using the “import blueprint” button above get the following error:

Invalid blueprint: not a valid value for dictionary value @ data['blueprint']['input']['source_url']. Got 'https://github.com/foglietti/Home-Assistant-Blueprints/blob/c9e21d6a51f27fce62c880eeb2e06ca808d17b77/aqara_wireless_remote_double_switch_WXKG02LM_rev2_z2m.yaml'

Are you able to help sorry?

Hi,

Try to donwload it, the link should work now.
There was an error in the URL.

Thanks.

1 Like

Working excellent now - thanks Foglietti!

1 Like

Thanks for the updated blueprint.
Unfortunately it doesn’t work for me while I have the
WXKG02LM_rev2 paired in z2m. I can also see the event triggers when checking states.

I think the problem is with the helper. I’m not so familiar with this feature. But I created the helper through the blueprint. Assigned a key to a device and pressed button but nothing happens.

I also tested the aqara all in one (believe it’s yours as well) and this one works out of straight away. I could use that one but this one has less options which you can conffigure which fits with my needs.

Any suggestion what the issue could be?

I used this

The problem could be the MQTT topic.
The correct topic should be “zigbee2mqtt/Name of the switch”, you entered “zigbee2mqtt/homeassistant”. Try to put the correct name of your switch.

1 Like

Thanks I misunderstood that part.
I got it working again. Appreciate and the tip and especially the changes in the blueprint! :slight_smile:

1 Like