ZHA - Aqara Wireless Remote Switch (Double Rocker)

Yeah maybe. Theres a feature request open (Allow using a list in blueprint selectors) so you cann add a list of model numbers to avoid this. But state of the art you can only use a wider selector

Alright, I was able to get it working in an automation, but not in your blueprint. I’m only getting 3 triggers from it, left, right, and both. Luckily, that works for my uses. It doesn’t look like my device integration is passing on the device_id, which is a long string of characters. The buttons are tied to the" endpoint_id" which goes 1=left, 2=right, 3=both. I’m happy having gotten this figured out. Thank you for your help!

Here’s how it turned out.

alias: Double Rocker Left Button
description: 'Automation for Aqara Double Rocker Model WXKG02LM'
mode: single
trigger:
  - platform: event
    event_type: zha_event
    event_data:
      device_id: #get your device ID from listening to zha_event in the Developer Tools Event's tab
      endpoint_id: 1
action:
  service: homeassistant.toggle
  entity_id: light.shelly_1_light
1 Like

Okay So I could convert this to a blueprint if you like, then you have one blueprint/automation and not 3 seperate ones for each type of button press

1 Like

Thank you, but I’m okay with my automations. I just wanted to be sure to post it here in case anyone else is looking for the information.

1 Like

yes please same issue here

Sorry for replying late, I’m in the mid of my exams for this semester. I modified my blueprint for the lumi.sensor_86sw2 model one given by the information of @looknsharp . You have to test it by your own though, because I have the lumi.remote.b286acn01 one.

blueprint:
  name: ZHA - Aqara Wireless Remote Switch (Double Rocker)
  description: Automate your Xiaomi Aqara Wireless Remote Switch (Double Rocker) (lumi.sensor_86sw2 Version) 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_press_left:
      name: Single Press Left
      description: Action to run on single press
      default: []
      selector:
        action:
    button_press_right:
      name: Single Press Right
      description: Action to run on single press
      default: []
      selector:
        action:
    button_press_both:
      name: Single Press Both Buttons
      description: Action to run on single presses
      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.endpoint_id}}"

  - choose:
      - conditions:
          - "{{ command == 1 }}"
        sequence: !input button_press_left
      - conditions:
          - "{{ command == 2 }}"
        sequence: !input button_press_right
      - conditions:
          - "{{ command == 3 }}"
        sequence: !input button_press_both
1 Like

Hi and a big thank you for this blueprint.

Do you know of any (easy) way to make the long press on each button to increase and decrease the brightness of a light?

Can this be done using your blueprint and a script, automation, input boolean? Or must we go via the custom yaml path?

I truly believe that increasing and decreasing the brightness via long press is searched and wanted by many users and I also think it would be a great addition to the functionality of switches such as this one.

Because the switch hasnt a event when a button is released, theres no clean and good way for that. One workaround could be to execute a script with a repeat loop which checks if a button is pressed. eg if you hold the left button long, you can repeat the increase brightness until the left button is short pressed (you have to work with a event).

Dont know if this works, but its the only solution i can imagine. As said, there is no clean solution i know of for that switch

Thank you very much sir, you saved my day hehe

Ive just moved over to ZHA and apparently I have a mixture of the 2 different types and this topic has been a huge help.
For those that identify as lumi.sensor_86sw2 they support press and release so the blueprint posted above to make these things work is triggered every time the button is pressed. This means a simple light toggle doesnt work.

Ive modified the blueprint for this.

blueprint:
  name: ZHA - Aqara Wireless Remote Switch (Double Rocker 86sw2)
  description: Automate your Xiaomi Aqara Wireless Remote Switch (Double Rocker) (lumi.sensor_86sw2 Version) 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_press_left:
      name: Single Press Left
      description: Action to run on single press
      default: []
      selector:
        action:
    button_press_right:
      name: Single Press Right
      description: Action to run on single press
      default: []
      selector:
        action:
    button_press_both:
      name: Single Press Both Buttons
      description: Action to run on single presses
      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.endpoint_id }}"
      pressed: "{{ trigger.event.data.args.value }}"

  - choose:
      - conditions:
          - "{{ command == 1 }}"
          - "{{ pressed == 'Bool.true' }}"
        sequence: !input button_press_left
      - conditions:
          - "{{ command == 2 }}"
          - "{{ pressed == 'Bool.true' }}"
        sequence: !input button_press_right
      - conditions:
          - "{{ command == 3 }}"
          - "{{ pressed == 'Bool.true' }}"
        sequence: !input button_press_both

I have no idea why pressed cannot simply be true or false but it works and im sure theres someone way smarter than me out there that can pointout what the hell is going on.

4 Likes

Hi there, I also have WXKG02LM, and I having trouble to make this work. I would prefer the blueprint. Can you share it?

Hi,
I have a Wireless Remote Switch H1 Double Rocker made in 05/2021 and bought from a web shop in France.
Entity is lumi.remote.b28ac1.

I had great hope from this blueprint but sadly it doesn’t work for me :frowning: like… of course :stuck_out_tongue:
Nothing happens with it.

Event with whatever I do (left/right/single/long/double):
Only two informations change: “time_fired” and “context”: { “id” }

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "54:ef:44:10:00:12:37:94",
        "unique_id": "54:ef:44:10:00:12:37:94:1:0x0006",
        "device_id": "11da6dd18dba7fe06d7c72f2ef7416fd",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "toggle",
        "args": []
    },
    "origin": "LOCAL",
    "time_fired": "2021-10-15T11:48:55.825210+00:00",
    "context": {
        "id": "07d05d0f5174d45f9600a320e1d3b0ee",
        "parent_id": null,
        "user_id": null
    }
}

FYI, I can create an automation with this trigger:

platform: event
event_type: zha_event
event_data:
  device_id: 11da6dd18dba7fe06d7c72f2ef7416fd
  endpoint_id: 1

Can I do something myself? Like tweaking a little something?
Or is it again a different product? If so would you be so kind to update your blueprint? :slight_smile:

Anyway, thanks for your great work on this!

Hi @NachtaktiverHalbaffe ,
ive been trying to get the Aqara Wireless Remote Switch H1 Double Rocker to work with Odroid N2+ Home Assistant Blue, using a ConBee II USB Zigbee-controller.
as per the info in settings its a Aqara 2019 modell.

i managed to add the device, but when checking the zha_event i get the same event over and over.
doset matter if i double click (left or right), hold (left or right) or just simple click (left or right).

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "54:ef:44:10:00:06:51:5e",
        "unique_id": "54:ef:44:10:00:06:51:5e:1:0x0006",
        "device_id": "064fbd90b296072636c8ec97f2d818b8",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "toggle",
        "args": []
    },
    "origin": "LOCAL",
    "time_fired": "2021-10-25T16:12:27.091423+00:00",
    "context": {
        "id": "a0cb3a09fe4fa9ae0da921f0cfe1b473",
        "parent_id": null,
        "user_id": null
    }
}
Event 0 fired 18:12:
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "54:ef:44:10:00:06:51:5e",
        "unique_id": "54:ef:44:10:00:06:51:5e:1:0x0006",
        "device_id": "064fbd90b296072636c8ec97f2d818b8",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "toggle",
        "args": []
    },
    "origin": "LOCAL",
    "time_fired": "2021-10-25T16:12:26.423373+00:00",
    "context": {
        "id": "871236f6fb34baa3e5d658451c9d12cb",
        "parent_id": null,
        "user_id": null
    }
}

So just to be clear.
Will i need both the integration for zigbee and deCONZ?
Tried both tho, when just using the Zigbee integration i get the event logs, while on deCONZ i dont get any event logs.

Im a 100% new to this, so please do state even the obvious.

Best regards, a confused swede

Hi! I am in exactly the same situation as you.
I have the same model and I have the same problem, you can only use the two buttons as if it were a device …

Did you get something else? Do you think there will be any improvement in this?

Sounds like zha needs to add a quirk to fix these devices

ZHA Device Handlers
ZHA deviation handling in Home Assistant relies on the third-party ZHA Device Handlers project. Zigbee devices that deviate from or do not fully conform to the standard specifications set by the Zigbee Alliance may require the development of custom ZHA Device Handlers (ZHA custom quirks handler implementation) to for all their functions to work properly with the ZHA component in Home Assistant. These ZHA Device Handlers for Home Assistant can thus be used to parse custom messages to and from non-compliant Zigbee devices. The custom quirks implementations for zigpy implemented as ZHA Device Handlers for Home Assistant are a similar concept to that of Hub-connected Device Handlers for the SmartThings platform as well as that of zigbee-herdsman converters as used by Zigbee2mqtt, meaning they are each virtual representations of a physical device that expose additional functionality that is not provided out-of-the-box by the existing integration between these platforms.

I’ve got 2 double rockers in my livingroom and got an easy fix for you I think. Forget the ZHA_Event but use the swith that ZHA created in HA.

1: create a helper variable: input_select.livingroom_mode with the modes you want to use. I have a couple of different modes: Daytime, evening, TV & Off
2: create an automation to run trough the options using the rocker

alias: Lampen - Knop 2
description: ''
trigger:
  - entity_id: switch.zmuurknop2
    platform: state
    to: 'on'
  - entity_id: switch.zmuurknop2
    platform: state
    to: 'off'
action:
  - service: input_select.select_next
    target:
      entity_id: input_select.livingroom_mode 
mode: single

3: for each setting you create a different automation

Daytime:

alias: Lampen - Knop 2 (daytime)
description: ''
trigger:
  - entity_id: input_select.livingroom_mode 
    platform: state
    to: dag
action:
  - data:
      brightness: 254
      color_temp: 200
    entity_id: light.woonkamer_lampen
    service: light.turn_on
  - data: {}
    entity_id: switch.stekker5
    service: switch.turn_off
mode: single

TV

alias: Lampen - Knop 2 (tv)
description: ''
trigger:
  - entity_id: input_select.livingroom_mode 
    platform: state
    to: tv
action:
  - data:
      brightness: 60
      color_temp: 440
    entity_id: light.woonkamer_lampen
    service: light.turn_on
  - data: {}
    entity_id: switch.stekker5
    service: switch.turn_on
mode: single

and so on

One of the rockers I’ve got here is set to turn everything off

alias: Lampen - Knop 4 - woonkamer uit
description: ''
trigger:
  - entity_id: switch.zmuurknop4
    platform: state
action:
  - data:
      option: off
    entity_id: input_select.livingroom_mode 
    service: input_select.select_option
mode: single

I’ve been using this setup little over a year and still like how it works. Hope you can make something that works for you with this idea.

Hello Nato, To me it does not create an entity with the switch, it only creates a battery sensor in unknown state.
Could you take a screenshot of how the device is displayed in ZHA? Or some more detailed information about how you get the two switch entities, one for each button?

It looks something like this

image

My controller is currently not working, that’s why it sais disabled

I’ve had devices that joined ZHA incomplete, after one or 2 times rejoining them they would show up in the proper way.

Nevermind. Got it working!

@Mace How dit you got it working? I’m having the same problem, but nothing I do seems to work.