[Z2M] Aqara Opple 4 boutons blueprint (WXCJKG12LM) [Updated 2025]

Hello everyone,

I’m sharing my blueprint on Aqara Opple 4 boutons (WXCJKG12LM) for zigbee2mqtt.

You can find the two button (one band) version here and six button (three band) version here.

This blueprint has no default values.

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

blueprint:
  name: Z2M - Aqara Opple switch 2 bands (4 buttons)
  description: 'Control anything you want with Aqara Opple switch 2 bands (WXCJKG12LM).

    This blueprint was updated in January 2025 to stop facing the issues I had with
    the old one.

    I''m overwritting the old one as it used actions that are now long deprecated

    Each band button has single, double, triple, hold & release'
  author: Christian Bouyssi
  homeassistant:
    min_version: 2025.1.0
  domain: automation
  input:
    device_selection:
      name: Select the device you want to configure
      description: Aqara switch to use
      selector:
        device:
          filter:
          - integration: mqtt
            model: Opple wireless switch (double band)
          - integration: mqtt
            model: Opple wireless switch (double band) (WXCJKG12LM)
          multiple: false
    button_1_section:
      name: Actions for button 1
      icon: mdi:numeric-1-box
      collapsed: true
      input:
        button_1_single:
          name: Single click
          description: Action to run on single click
          default: []
          selector:
            action: {}
        button_1_double:
          name: Double click
          description: Action to run on double click
          default: []
          selector:
            action: {}
        button_1_triple:
          name: Triple click
          description: Action to run on triple click
          default: []
          selector:
            action: {}
        button_1_hold:
          name: Hold button
          description: Action to run on hold
          default: []
          selector:
            action: {}
        button_1_release:
          name: Release button
          description: Action to run after hold then release
          default: []
          selector:
            action: {}
    button_2_section:
      name: Actions for button 2
      icon: mdi:numeric-2-box
      collapsed: true
      input:
        button_2_single:
          name: Single click
          description: Action to run on single click
          default: []
          selector:
            action: {}
        button_2_double:
          name: Double click
          description: Action to run on double click
          default: []
          selector:
            action: {}
        button_2_triple:
          name: Triple click
          description: Action to run on triple click
          default: []
          selector:
            action: {}
        button_2_hold:
          name: Hold button
          description: Action to run on hold
          default: []
          selector:
            action: {}
        button_2_release:
          name: Release button
          description: Action to run after hold then release
          default: []
          selector:
            action: {}
    button_3_section:
      name: Actions for button 3
      icon: mdi:numeric-3-box
      collapsed: true
      input:
        button_3_single:
          name: Single click
          description: Action to run on single click
          default: []
          selector:
            action: {}
        button_3_double:
          name: Double click
          description: Action to run on double click
          default: []
          selector:
            action: {}
        button_3_triple:
          name: Triple click
          description: Action to run on triple click
          default: []
          selector:
            action: {}
        button_3_hold:
          name: Hold button
          description: Action to run on hold
          default: []
          selector:
            action: {}
        button_3_release:
          name: Release button
          description: Action to run after hold then release
          default: []
          selector:
            action: {}
    button_4_section:
      name: Actions for button 4
      icon: mdi:numeric-4-box
      collapsed: true
      input:
        button_4_single:
          name: Single click
          description: Action to run on single clic
          default: []
          selector:
            action: {}
        button_4_double:
          name: Double click
          description: Action to run on double click
          default: []
          selector:
            action: {}
        button_4_triple:
          name: Triple click
          description: Action to run on triple click
          default: []
          selector:
            action: {}
        button_4_hold:
          name: Hold button
          description: Action to run on hold
          default: []
          selector:
            action: {}
        button_4_release:
          name: Release button
          description: Action to run after hold then release
          default: []
          selector:
            action: {}
  source_url: https://community.home-assistant.io/t/z2m-aqara-opple-4-boutons-blueprint-wxcjkg12lm/279950
mode: restart
max_exceeded: silent
triggers:
- domain: mqtt
  device_id: !input device_selection
  type: action
  subtype: button_1_single
  trigger: device
- domain: mqtt
  device_id: !input device_selection
  type: action
  subtype: button_1_double
  trigger: device
- domain: mqtt
  device_id: !input device_selection
  type: action
  subtype: button_1_triple
  trigger: device
- domain: mqtt
  device_id: !input device_selection
  type: action
  subtype: button_1_hold
  trigger: device
- domain: mqtt
  device_id: !input device_selection
  type: action
  subtype: button_1_release
  trigger: device
- domain: mqtt
  device_id: !input device_selection
  type: action
  subtype: button_2_single
  trigger: device
- domain: mqtt
  device_id: !input device_selection
  type: action
  subtype: button_2_double
  trigger: device
- domain: mqtt
  device_id: !input device_selection
  type: action
  subtype: button_2_triple
  trigger: device
- domain: mqtt
  device_id: !input device_selection
  type: action
  subtype: button_2_hold
  trigger: device
- domain: mqtt
  device_id: !input device_selection
  type: action
  subtype: button_2_release
  trigger: device
- domain: mqtt
  device_id: !input device_selection
  type: action
  subtype: button_3_single
  trigger: device
- domain: mqtt
  device_id: !input device_selection
  type: action
  subtype: button_3_double
  trigger: device
- domain: mqtt
  device_id: !input device_selection
  type: action
  subtype: button_3_triple
  trigger: device
- domain: mqtt
  device_id: !input device_selection
  type: action
  subtype: button_3_hold
  trigger: device
- domain: mqtt
  device_id: !input device_selection
  type: action
  subtype: button_3_release
  trigger: device
- domain: mqtt
  device_id: !input device_selection
  type: action
  subtype: button_4_single
  trigger: device
- domain: mqtt
  device_id: !input device_selection
  type: action
  subtype: button_4_double
  trigger: device
- domain: mqtt
  device_id: !input device_selection
  type: action
  subtype: button_4_triple
  trigger: device
- domain: mqtt
  device_id: !input device_selection
  type: action
  subtype: button_4_hold
  trigger: device
- domain: mqtt
  device_id: !input device_selection
  type: action
  subtype: button_4_release
  trigger: device
actions:
- choose:
  - conditions:
    - condition: template
      value_template: '{{ trigger.payload == ''button_1_single'' }}'
    sequence: !input button_1_single
  - conditions:
    - condition: template
      value_template: '{{ trigger.payload == ''button_1_double'' }}'
    sequence: !input button_1_double
  - conditions:
    - condition: template
      value_template: '{{ trigger.payload == ''button_1_triple'' }}'
    sequence: !input button_1_triple
  - conditions:
    - condition: template
      value_template: '{{ trigger.payload == ''button_1_hold'' }}'
    sequence: !input button_1_hold
  - conditions:
    - condition: template
      value_template: '{{ trigger.payload == ''button_1_release'' }}'
    sequence: !input button_1_release
  - conditions:
    - condition: template
      value_template: '{{ trigger.payload == ''button_2_single'' }}'
    sequence: !input button_2_single
  - conditions:
    - condition: template
      value_template: '{{ trigger.payload == ''button_2_double'' }}'
    sequence: !input button_2_double
  - conditions:
    - condition: template
      value_template: '{{ trigger.payload == ''button_2_triple'' }}'
    sequence: !input button_2_triple
  - conditions:
    - condition: template
      value_template: '{{ trigger.payload == ''button_2_hold'' }}'
    sequence: !input button_2_hold
  - conditions:
    - condition: template
      value_template: '{{ trigger.payload == ''button_2_release'' }}'
    sequence: !input button_2_release
  - conditions:
    - condition: template
      value_template: '{{ trigger.payload == ''button_3_single'' }}'
    sequence: !input button_3_single
  - conditions:
    - condition: template
      value_template: '{{ trigger.payload == ''button_3_double'' }}'
    sequence: !input button_3_double
  - conditions:
    - condition: template
      value_template: '{{ trigger.payload == ''button_3_triple'' }}'
    sequence: !input button_3_triple
  - conditions:
    - condition: template
      value_template: '{{ trigger.payload == ''button_3_hold'' }}'
    sequence: !input button_3_hold
  - conditions:
    - condition: template
      value_template: '{{ trigger.payload == ''button_3_release'' }}'
    sequence: !input button_3_release
  - conditions:
    - condition: template
      value_template: '{{ trigger.payload == ''button_4_single'' }}'
    sequence: !input button_4_single
  - conditions:
    - condition: template
      value_template: '{{ trigger.payload == ''button_4_double'' }}'
    sequence: !input button_4_double
  - conditions:
    - condition: template
      value_template: '{{ trigger.payload == ''button_4_triple'' }}'
    sequence: !input button_4_triple
  - conditions:
    - condition: template
      value_template: '{{ trigger.payload == ''button_4_hold'' }}'
    sequence: !input button_4_hold
  - conditions:
    - condition: template
      value_template: '{{ trigger.payload == ''button_4_release'' }}'
    sequence: !input button_4_release

Changelog:

  • Jan 6. 2025: Removed multiple device support
  • Jan 5. 2025: Fixed typo, thanks @DSLeX. Added multiple device support
  • Jan 4. 2025: Long overdue overall of this blueprint. Overwrote the old one as it was using actions that are deprecated today
  • Feb 7. 2022: Added Release action to all switches

Don’t hesitate to let me know if there are issues. I’ll try to solve them as soon as possible.
Have a great time & stay safe
Chris

1 Like

Could you please also add the bits for release of a button hold? I think those are button_1_release, button_2_release, etc. Thanks!!

Hi @baru .

I’m sorry, I’m in the middle of moving from one region of France to another. All of Home Assistant is right now in a cardboard box in storage waiting for me to find a new house. I wont be able to do this for a while.

Don’t hesitate to take this template and improve it on your own as I can’t maintain it for now.

Cheers

Is there someone that can help me? I’m trying to use Opple with a Sonoff 4ch Pro tasmotized and used on HA as a Cover. I’d like to make the following:

When I press button 1 → I’d open the cover (therefore call the service cover.open)
When I press again button 1 → I’d stop the cover (therefore call the service cover.stop)

Do you have any idea on how to do that? Shall I modify the blueprint or create a specific automation?

Thanks

Anyone have this working in ZHA?

Would cover.toggle suit your use case?

1 Like

Aqara Opple 6 Buttons For Zha Looks like what you’re after

@baru ,

I’m finally back on HA ! Took a s*** ton of time sorry. I’ve added what you needed.

Haven’t had a chance to test it unfortunately

Hi all, and thank you for sharing.
I’ve a blueprint that is written in the same way but it has been developed for xiaomi clicker that works almost same way but with just one button.
I cannot manage the automation to work because of this:
Error: UndefinedError: ‘dict object’ has no attribute ‘to_state’
I tried also to change the variable definition in many ways solving the error, but the variable “command” seems to be always empty. Could you please advise?

I could well be doing something wrong but it seems like the state change isn’t triggering the automation for me. I’m using Zigbee2MQTT and HA running as docker containers.
I can see the following state change received:

"event_type": "state_changed",
...
        "new_state": {
            "entity_id": "sensor.0x54ef44100042b717_action",
            "state": "button_2_single",
...

However the automation for “button_2_single” doesn’t run.
Is anyone else seeing issues like this?

Hi @hypnosis ,

Sorry I didn’t get back to you earlier. It’s hard to say with the information at hand.

I would advise you to open a thread (not in the Blueprints exchange though, to have better visibility by everyone), with all details about the integration and what you do exactly for testing.

Otherwise it will be hard to help you out.
Chris

Might very well be me mate ! :slight_smile:

I have installed one though some weeks ago at home and it’s working great.

I confirm this is the same kind of event I receive. As details this is what happens on my side:

Event 53 fired 9:37 AM:
{
    "event_type": "state_changed",
    "data": {
        "entity_id": "sensor.kitchen_remote_action",
        "old_state": {
            "entity_id": "sensor.kitchen_remote_action",
            "state": "button_2_single",
            "attributes": {
                "action": "",
                "battery": 100,
                "linkquality": 96,
                "operation_mode": null,
                "temperature": 25,
                "voltage": 3059,
                "icon": "mdi:gesture-double-tap",
                "friendly_name": "Kitchen Remote action"
            },
            "last_changed": "2022-04-28T07:37:03.316789+00:00",
            "last_updated": "2022-04-28T07:37:03.332157+00:00",
            "context": {
                "id": "dcfa88aac6349889fc4b96928b1823c5",
                "parent_id": null,
                "user_id": null
            }
        },
        "new_state": {
            "entity_id": "sensor.kitchen_remote_action",
            "state": "",
            "attributes": {
                "action": "",
                "battery": 100,
                "linkquality": 96,
                "operation_mode": null,
                "temperature": 25,
                "voltage": 3059,
                "icon": "mdi:gesture-double-tap",
                "friendly_name": "Kitchen Remote action"
            }...

This is then followed automatically by:

Event 54 fired 9:37 AM:
{
    "event_type": "automation_triggered",
    "data": {
        "name": "Kitchen Remote",
        "entity_id": "automation.z2m_aqara_opple_switch_2_bands",
        "source": "state of sensor.kitchen_remote_action"
    },
    "origin": "LOCAL",
    "time_fired": "2022-04-28T07:37:03.352382+00:00",
    "context": {
        "id": "5492a98e9f94642fa06d38eaad92c6ab",
        "parent_id": "dcfa88aac6349889fc4b96928b1823c5",
        "user_id": null
    }
}

Maybe you can send me the details of your automation configuration?
Thanks
Chris

Wow, thanks, I didn’t expect such quick responses!

In working on the issue, I stumbled upon the following thread which mentions that the problem is likely that the state "button_1_single” is being set and then immediately being set back to an empty string.

This correlates with the events that I’m seeing when debugging.
To workaround it, I implemented code similar to the last post in that thread, making a separate automation for each button press.

I had never noticed that but yes you are right ! Fortunately for me it doesn’t seem to bother my automation. It sill triggers all right every time I press the button. And it makes sense because what triggers the rule, is the state_change. So whether it goes back to NULL shouldn’t impact the automation execution…

Are you running the blueprint as the automation directly? Or something else?

Cheers

That is what I thought initially too.
Yes, I created an automation directly from the blueprint.
Are you running Z2M and HA dockerized? I’m wondering whether that makes any difference.

One other thing to note (and I’m not sure if it matters or not) is that my Z2M configuration.yaml file has “homeassistant_legacy_entity_attributes” disabled.

Unfortunately I’m only relatively new to HA so my debugging abilities there are fairly limited.

Cheers,
Brent

Hey @brash,

Not anymore. Right now am running HA OS on an Intel Nuc.

I was looking at your setting that I didn’t know and I stumbled on another setting called legacy_triggers. The documentation says:

  # Optional: Home Assistant legacy triggers (default: shown below), when enabled:
  # - Zigbee2mqt will send an empty 'action' or 'click' after one has been send
  # - A 'sensor_action' and 'sensor_click' will be discoverd
legacy_triggers: true

Maybe you can set that option to false (default is ON). That would prevent the empty value from being sent?

I checked my settings and indeed… it’s enabled. Careful that changing this setting requires an HA restart

Here is the link to the doc

See you!

Interesting…
I come across with exactly same problem: Z2M, the blueprint and WXCJKG12LM… and HA on docker (moving slowly from Hassos)

Somehow this one particular blueprint don’t want to work.

So I made simple automation test:

alias: test1b
description: ''
trigger:
  - platform: state
    entity_id:
      - sensor.aqara4button_action
    to: button_1_single
condition: []
action:
  - service: switch.toggle
    data: {}
    target:
      device_id: d875be96231967c96acaac5930395d10
mode: single

and this works perfectly well.

I wonder what is the difference between the blueprint and this simple auto?
I love the blueprint, simplifies configuration a lot.

Hey @marekorok ,

That’s interesting !

To be fair i’ve no idea what the difference between the two are…

I just opened the blueprint and everything looks allright :frowning:

Something just caught my interest though, can you check your Z2M logs and press on one of the remotes buttons?

Mine shows this:

Info <small>2022-05-10 22:03:28</small>`MQTT publish: topic 'zigbee2mqtt/Kitchen Remote', payload '{"action":"","battery":100,"linkquality":96,"operation_mode":null,"temperature":25,"voltage":3075}'`

Info <small>2022-05-10 22:03:28</small>`MQTT publish: topic 'zigbee2mqtt/Kitchen Remote/action', payload 'button_4_single'`

What is bothering me is the “operation_mode” of the remote as null. Are you seing something else yourselves?

@Brash did you get any luck on this?

I might need to rework this blueprint all together, but since it is working at home, I don’t really have the will power to do so :rofl:

yes, I see the same operation_mode: null

If I get it right, it is used when you want to change binding and control directly something (like bulb) not using coordinator, from z2m doc:
https://www.zigbee2mqtt.io/devices/WXCJKG13LM.html#binding
by default it works in event mode.

I have even forced ‘event’ setting following the documentation but no change for blueprint, still does not work.

Info <small>2022-05-11 10:38:42</small>`MQTT publish: topic 'zigbee2mqtt/Aqara4Button', payload '{"action":"button_1_single","battery":100,"linkquality":174,"operation_mode":"event","voltage":3037}'`
Info <small>2022-05-11 10:38:42</small>`MQTT publish: topic 'zigbee2mqtt/Aqara4Button', payload '{"action":"","battery":100,"linkquality":174,"operation_mode":"event","voltage":3037}'`
Info <small>2022-05-11 10:38:42</small>`MQTT publish: topic 'zigbee2mqtt/Aqara4Button/action', payload 'button_1_single'`

I guess it’s irrelevant in our case

I agree, not relevant in this situation.

Can you check your automation using the blueprint traces to see if the event of pressing the button is actually even recorded there and why the action is not being triggered?