ZHA - Aqara Wireless Remote Switch (Double Rocker)

This blueprint will let you configure a Aqara Wireless Remote Switch (Double Rocker) (Eu Version) which is paired with ZHA. It supports commands for single, double and long-press for each rocker or both rockers together.

There is also an blueprint out there for the single rocker version of the switch: ZHA - Aqara Wireless Remote Switch (Single Rocker).

Requirements:

  • Aqara Wireless Remote Switch (Double Rocker). Be patient to select the right device, because there can be also other Lumi/Aqara devices in the list that arent compatible with this automation (See changelog for details)
  • ZHA integration

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

Blueprint:

blueprint:
  name: ZHA - Aqara Wireless Remote Switch (Double Rocker)
  description: Automate your Xiaomi Aqara Wireless Remote Switch (Double Rocker) using ZHA events.
  domain: automation
  input:
    aqara_mini_switch:
      name: Select the Aqara Wireless Remote Switch (Double Rocker)
      description: Aqara Wireless Remote Switch (Double Rocker)
      selector:
        device:
          integration: zha
          manufacturer: LUMI
          entity:
            domain: sensor
            device_class: battery
    button_single_press_left:
      name: Single Press Left
      description: Action to run on single press
      default: []
      selector:
        action:
    button_double_press_left:
      name: Double Press Left
      description: Action to run on double press
      default: []
      selector:
        action:
    button_long_press_left:
      name: Long Press Left
      description: Action to run when button is long pressed (held down)
      default: []
      selector:
        action:
    button_single_press_right:
      name: Single Press Right
      description: Action to run on single press
      default: []
      selector:
        action:
    button_double_press_right:
      name: Double Press Right
      description: Action to run on double press
      default: []
      selector:
        action:
    button_long_press_right:
      name: Long Press Right
      description: Action to run when button is long pressed (held down)
      default: []
      selector:
        action:
    button_single_press_both:
      name: Single Press Both Buttons
      description: Action to run on single presses
      default: []
      selector:
        action:
    button_double_press_both:
      name: Double Press Both Buttons
      description: Action to run on double presses
      default: []
      selector:
        action:
    button_long_press_both:
      name: Long Press Both Buttons
      description: Action to run when buttons are long pressed (held down)
      default: []
      selector:
        action:

mode: restart
max_exceeded: silent

trigger:
  - platform: event
    event_type: zha_event
    event_data:
      device_id: !input aqara_mini_switch

action:
  - variables:
      command: "{{ trigger.event.data.command }}"

  - choose:
      - conditions:
          - "{{ command == 'left_single' }}"
        sequence: !input button_single_press_left
      - conditions:
          - "{{ command == 'left_double' }}"
        sequence: !input button_double_press_left
      - conditions:
          - "{{ command == 'left_long press' }}"
        sequence: !input button_long_press_left
      - conditions:
          - "{{ command == 'right_single' }}"
        sequence: !input button_single_press_right
      - conditions:
          - "{{ command == 'right_double' }}"
        sequence: !input button_double_press_right
      - conditions:
          - "{{ command == 'right_long press' }}"
        sequence: !input button_long_press_right
      - conditions:
          - "{{ command == 'both_single' }}"
        sequence: !input button_single_press_both
      - conditions:
          - "{{ command == 'both_double' }}"
        sequence: !input button_double_press_both
      - conditions:
          - "{{ command == 'both_long press' }}"
        sequence: !input button_long_press_both

Changelog

  • 2020-12-24: Fixed Typo (Thanks rvst1Stefan)
  • 2020-12-29: Added Actions if both buttons are pressed once, twice ore held down (Thanks Jonah1970Mark)
  • 2021-01-01: The Selector was specified to the model lumi.remote.b286acn01, but seems that are also lumi.remote.b286acn02 (and maybe more) available. As a consequence the selector is now more open and accepts all Lumi devices in the ZHA-Integration which have a battery. So be patient to select the right device because there can be other Lumi-devices in the list which arent compatible (Thanks TimmiT93Tim)
14 Likes

Thanks for this Blueprint! Just tried it with the switch I had laying around. Works flawless.

Just a quick info. In the description the “Device picker” says Aqara Wireless Mini Switch to use. Should probably be renamed (most likely a copy and paste error :slight_smile:)

Thanks! I fixed the Typo tonight

1 Like

If this is the WXKG07LM then these remotes also support the single/double/long presses of both buttons simultaneously (i.e. not just the left and right). This gives 9 separate functions rather than 6.

Oh, didnt know the switch had this functionality. I bought it to control two lights independently, so I forgot this cause I didnt need it.

I updated the blueprint. Thanks!

1 Like

Hi, this blueprint looks great!! :slight_smile:
I’m currently moving away from Samsung SmartThings to HomeAssistant and I’m very pleased so far.

I bought the Aqara Wireless Remote Switch very recently. It is the D1 version with serial number WXKG07LM. It is successfully connected to HomeAssistant, but I’m unable to use it with this blueprint. Possibly because the model number in HomeAssistant shows lumi.remote.b286acn02, so with a 2 at the end. Is it possible to add this device to the selector for this blueprint?

Kind regards and best wishes for 2021!

Tim

Okay it seems that there are more model numbers available (maybe due to regional differences). I tried to give a list of model numbers to the selector, but didnt work. So I dont know how to add multiple model numbers, so I opend the selector.

Now in the selector are all Lumi (Aqara) with a battery entity which are configured in ZHA are available. Your wall switch should now be found, but as a consequence there can be more devices of Lumi be shown which wont work with this blueprint. So be patient to select the right device :wink:

If anyone has a solution to put multiple model numbers in the selector, then let me know so i can fix it properly so that are only all Aqara Wireless Remote Switches (Double Rocker) are shown.

1 Like

I’ve been unable to get my WXKG02LM to work with this. How can I best help contribute?

1 Like

Yeah this blueprint is for the WXKG07LM, which seems to be the EU one which is adapted to the stricter data security laws. Seems that there are also technical differences between the models.

I need some more infomation about your problem and make sure that simple mistakes werent causing your issues. I dont know how good your knowledge in HA is, so some of them can see trivial for you.

  • Is the switch paired with ZHA and does show up under your devices (should be named lumi.remote.b286acn01 or something similiar)? The blueprint does not work with zigbee2mqtt or conbee
  • If it is paired with ZHA, what is the name of the device and the model number?
  • What does not work exactly?
  • Can you select your device in the blueprint or is the right device selected (There can also show up some other aquara devices which arent your switch)? Is the automation created with your selected inputs or is the problem in creating the automation?
  • Have you changed the actions to simple example actions which you definitly know they work?

If you can answer all of this with yes, then we have to dive deeper into the blueprint. If you know how to edit yaml-Files, you can hear in the developer tools for “zha_event” and click every single button. Afterwards you can check if the commands from my blueprint (located at blueprints/nachtaktiverhalbaffe/) and the ones you listened for in the developer tools matches. This way you can fix it yourself (make sure to reload automations afterwards) and we can look if both versions can be merged.

If you dont know/dont want to work with yaml, then you can still do the hearing for zha_event thing and can post the data for each event here so I can look onto this. Make sure to delete personal and unnecessary information from the event so it does look like this:

{
    "event_type": "zha_event",
    "data": {
        "command": "right_single",
        "args": {
            "button": "right",
            "press_type": "single",
            "attr_id": 85,
            "value": 1
        }
    },
}

I can’t promise I can fix this blueprint to work with your device. They look the same, but they could work completly different on the technical side. In the worst case we must create a new blueprint for the WXKG02LM type of switch.

Thanks for taking the time to respond. I am competent with HA, but not advanced. I’ve been able to get all my other Xiaomi/Aqara sensors working with ZHA, except this type. I have 2 of the WXKG07LM devices; I have 1 connected and it shows up as lumi.sensor_86sw2 in HA.

It’s paired fine, I am able to select it with the blueprint and make the automations, but it won’t trigger anything. Here’s what I’m seeing in my zha_event listening, which is VERY different that what you have and I haven’t been able to successfully edit the YAML to accommodate this data.

These are the results from pressing them each 2 times; left, right, left, right. It’s creating 1 or 2 events with no button or press_type available from the data. Each button is providing a different device ID and endpoint ID. Meaning the left button has it’s own device ID, and is endpoint 1, while the right button has a different device ID and is endpoint 2. I’ve edited out the MAC, unique ID, and device ID, but left in the endpoint ID to show which button was pressed.

Event 7 fired 4:33 PM:

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "EDITED_OUT",
        "unique_id": "EDITED_OUT",
        "device_id": "EDITED_OUT",
        "endpoint_id": 2,
        "cluster_id": 6,
        "command": "attribute_updated",
        "args": {
            "attribute_id": 0,
            "attribute_name": "on_off",
            "value": 0
        }
    },
    "origin": "LOCAL",
    "time_fired": "2021-01-07T00:33:40.413139+00:00",
    "context": {
        "id": "1d4c26909eb454dca08b1b77f34a617e",
        "parent_id": null,
        "user_id": null
    }
}

Event 6 fired 4:33 PM:

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "EDITED_OUT",
        "unique_id": "EDITED_OUT",
        "device_id": "EDITED_OUT",
        "endpoint_id": 2,
        "cluster_id": 6,
        "command": "attribute_updated",
        "args": {
            "attribute_id": 0,
            "attribute_name": "on_off",
            "value": 1
        }
    },
    "origin": "LOCAL",
    "time_fired": "2021-01-07T00:33:40.412679+00:00",
    "context": {
        "id": "5cb9aa6b8d2e71d27205db06abf91a4a",
        "parent_id": null,
        "user_id": null
    }
}

Event 5 fired 4:33 PM:

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "EDITED_OUT",
        "unique_id": "EDITED_OUT",
        "device_id": "EDITED_OUT",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "attribute_updated",
        "args": {
            "attribute_id": 0,
            "attribute_name": "on_off",
            "value": 0
        }
    },
    "origin": "LOCAL",
    "time_fired": "2021-01-07T00:33:38.862789+00:00",
    "context": {
        "id": "d099d890de2b31a4a552bba89cd3ef25",
        "parent_id": null,
        "user_id": null
    }
}

Event 4 fired 4:33 PM:

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "EDITED_OUT",
        "unique_id": "EDITED_OUT",
        "device_id": "EDITED_OUT",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "attribute_updated",
        "args": {
            "attribute_id": 0,
            "attribute_name": "on_off",
            "value": 1
        }
    },
    "origin": "LOCAL",
    "time_fired": "2021-01-07T00:33:38.862390+00:00",
    "context": {
        "id": "480e5c1561cbca3a441f19f92603ec42",
        "parent_id": null,
        "user_id": null
    }
}

Event 3 fired 4:33 PM:

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "EDITED_OUT",
        "unique_id": "EDITED_OUT",
        "device_id": "EDITED_OUT",
        "endpoint_id": 2,
        "cluster_id": 6,
        "command": "attribute_updated",
        "args": {
            "attribute_id": 0,
            "attribute_name": "on_off",
            "value": 0
        }
    },
    "origin": "LOCAL",
    "time_fired": "2021-01-07T00:33:34.871407+00:00",
    "context": {
        "id": "90833db7a23cd316943d634cd077ac88",
        "parent_id": null,
        "user_id": null
    }
}

Event 2 fired 4:33 PM:

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "EDITED_OUT",
        "unique_id": "EDITED_OUT",
        "device_id": "EDITED_OUT",
        "endpoint_id": 2,
        "cluster_id": 6,
        "command": "attribute_updated",
        "args": {
            "attribute_id": 0,
            "attribute_name": "on_off",
            "value": 1
        }
    },
    "origin": "LOCAL",
    "time_fired": "2021-01-07T00:33:34.870877+00:00",
    "context": {
        "id": "09ba09d120e286fc8177bb3c12915671",
        "parent_id": null,
        "user_id": null
    }
}

Event 1 fired 4:33 PM:

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "EDITED_OUT",
        "unique_id": "EDITED_OUT",
        "device_id": "EDITED_OUT",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "attribute_updated",
        "args": {
            "attribute_id": 0,
            "attribute_name": "on_off",
            "value": 0
        }
    },
    "origin": "LOCAL",
    "time_fired": "2021-01-07T00:33:30.623535+00:00",
    "context": {
        "id": "6043358417768ada278bbc9e1612dc1b",
        "parent_id": null,
        "user_id": null
    }
}

Event 0 fired 4:33 PM:

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "EDITED_OUT",
        "unique_id": "EDITED_OUT",
        "device_id": "EDITED_OUT",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "attribute_updated",
        "args": {
            "attribute_id": 0,
            "attribute_name": "on_off",
            "value": 1
        }
    },
    "origin": "LOCAL",
    "time_fired": "2021-01-07T00:33:30.622918+00:00",
    "context": {
        "id": "d3b49cf7c840d92ce1a32e0cb3928a0f",
        "parent_id": null,
        "user_id": null
    }
}

Yeah seems like the switches works kinda different as expected. My switch has a different command for each type of button press. Your command is always the same (“attribute_updated”) and send the information for the kind of button press in “args” and it subattributes. So this seems to be causing the problems. I am not sure if endpoint_id and cluster_id is neccessary to detect your kind of button press or if it is something that is unique to your zigbee network or not related to the kind of button press, thats a thing you have to find out in step 1 in the mentioned steps below.

You can try to repairing your switch and look if the events look the same, so we can be sure that these diffrences are because of different models and no issue with ZHA which seem to occur sometimes, I had to pair my switch also 2 times.

If its no ZHA-pairing issue, I see a way to merge both the WXKG02LM and the WXKG07LM to one working blueprint or we can seperate them into two different blueprints, each for the specific model. Dont know which solution is better. Netherless, for both ways these changes are needed:

  1. Hear for each type of button press for the zha event. To avoid mistakes, trigger the same event several times and clear the events when you going to hear for the next type of button press. I think each type of button press (eg. single press left) has its own unique combination of “attribute_id”, “attribute_name” and “value”. Write it down on e.g. a table with each combination of these attributes and what type of press it was triggered from. There should be 9 types of button presses if both switches support the same features

  2. Replace the variables. You can remove the variable command. You need the three above mentioned and the variable should look like the code below and so on

- variables:
      attribute_id: "{{ trigger.event.data.args.attribute_id}}" #could be also  "{{ trigger.event.data.args[0]}}", you have to try it out
      attribute_name: #and so on
  1. In the actions of the automations, you have to change the condition to match the button press like the code below (if I interpreted your event data right). Make shure if the squence takes an input from button_long_press_right, to match the conditions with the long button press of the right rocker :smile:
- conditions:
      - ""{{ attribute_id == 0  &&  attribute_name == 'on_off'  &&  value == 1}}""
  sequence: !input button_single_press_left
  1. Happy Testing. Should work now hopefully. You dont need to change the inputs and other stuff specific to the blueprint ( maybe change the name and description to seperate them from my blueprint). Make sure to test each type of button press to find typo mistakes.

Actually you only need to change the automation part of the blueprint and not specifically any stuff related with the blueprint part (e.g. inputs, selectors). You can try all this steps at your own as a practice to get depper into yaml editing in HA. The steps above should give you everything you need. :monkey:
Otherwise you can do step 1, send me the combination of the attributes via personal message, I’ll do step 2-3 and you do the testing afterwards until it works. I don’t have your type of switch, so finding out the combination and testing is every time up to you. Either way we could get this working I think.

This all looks great! Thank you so much. I’ll dig in this week and come back with more info. I have 2 of these switches, too. So, I’ll also be able to make sure they work the same as each other.

With a slight modification to the blueprint it also works for the Single Rocker version (WXKG03LM). You just need to look for commands “single”, “double” and “long press”. Perhaps you could add this to your blueprint?

Thats totally possible. My only question is if we should do a new blueprint for that because it’s a different device? In my philosophy for blueprints for ZHA-Devices there should be only one blueprint for 1 device so people can easily search for the ZHA device they need for automation.

If you agree, I or you can do a new blueprint for that and create a ne topic in the blueprint exchange. If not, I’m totally open for discussion about that topic. Its just my opinion and no official guideline

I don’t really have a strong opinion, and being new here I don’t know what “standards” there are. :slight_smile:

Personally I would probably do it all in one since the single & dual rocker versions are very similar. And probably map the “single” commands to the left button actions (and rename them button 1 (left) and button 2 (right)…

Yeah I think I will create a new one. We already have 10 Inputs and its kinda messy and for low level Hassio users it could get confusing where to add their stuff. I think for not so advanced users its easier to have a explicit one for the WXKG03LM where they can add their stuff just right away without worrying that you can add actions to the wrong place

Can you send me the model number of the switch so I can add this for the selector (The filter which determines if a entity could be selected in the input). I would send you the blueprint for testing per PN so you can test before we publish it if this is okay for you.

Later you can still merge both blueprints by your own for your personal use at home for your own instance.

I just created a new blueprint for the single rocker version: ZHA - Aqara Wireless Remote Switch (Single Rocker)
It’s based on this blueprint, but since it’s my first blueprint (I made it because I needed it today), I might have not created it correctly. If anyone has any improvements on it, go ahead and let me know :slight_smile:

1 Like

Checked it already. Seems that there arent obvious mistakes like typos. Could’nt check if the commands are right cause I havent the switch. If all the actions works for each kind of press then your blueprint is perfectly fine. I have it refrenced in my original post :+1:t4:

An option is to refrence the model number in the selector. I have mine cause that there are more model numbers out there for the double rocker. If this is the case for the single rocker one too then leave it as it is. If the single rocker one has only one model number, then change it like below and only the aquara single rocker switches are shown.

      selector:
        device:
          integration: zha
          manufacturer: LUMI
          model: xxxxxxx

So far everything works with the it (single, double, long press), so the commands are good too.

I only have one single rocker, and that one has a model number of WXKG03LM (my double rocker switch is model WXKG02LM). I tried to search around if there’s any other, and this site says it’s the EU version, so I guess there are multiple models. But this is not definitive, so maybe others will experience something different. I don’t know honestly.

I meant if your entity is called lumi.remote.b286acn02, then the b286acn02 part. Thought it was called the model number, but can be something else. Its a model specific size an can be put in the selector under “model” and is a way to filter the selector so only your model is shown and not toher stuff from the manuifacturer. This can also be overfilter the selector like in my case where was also a model b286acn01 out there :smile: Just as a information for future blueprints, especially useful for ZHA