[Z2M] Aqara Opple 4 boutons blueprint (WXCJKG12LM)

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?

I’ve had the same problem as people above - and I discovered the problem. The automation has this as a trigger:

trigger:
  - platform: state
    entity_id: !input "switch"
    attribute: action

But (and I’m not sure if this is a change in zigbee2mqtt or HA since this blueprint was written), but the sensor attribute which changes state to mark the MQTT even doesn’t have and attribute called ‘action’; it only has a state. Therefore, the automation is watching a non-existent attribute and never fires.

Removing the attribute: action line makes the automation work.