[Z2M] Aqara Opple 4 boutons blueprint (WXCJKG12LM)

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.

Hello @thecowan ,

Thanks a lot for pitching in in this.

That doesn’t explain why it works like a charm on my end. I’ll try to do the change on my side when I get out of work and test it. Then I’ll publish the template edited if everything works all right.

Hello again @thecowan ,

If I remove attribute:action on my end, the automation stops working all together.

It makes sense, since my sensor does have an action attribute.

From playing around more, I think this depends on whether you have “Home Assistant legacy entity attributes” set in the zigbee2mqtt config. If you do, you have an action attribute; if not, it’s kept purely in the state. I think.

1 Like

If you want to eliminate the null triggers from firing the automation thus causing errors in the log, add a condition to only allow the ‘good’ triggers to get into the blueprint guts and screen out the nulls and everything else in the condition…

I explained that to someone else here:

Hi all,

this might be a really dumb newbie question but I hope you don’t throw tomatoes at me now:

I imported this blueprint. I have an Opple WXCJKG12LM joined over deCONZ and showing up under “devices” and I can actually use it to trigger stuff (but without a blueprint of course rather unstructured).
But if I want to create an automation with this blueprint here, I can not select the Opple switch - the dropdown shows “no matching entities found”.

How can that be - the device is visible under “devices”?

I have the same thing also with another Aqara Switch (WXKG11LM) and it’s respective blueprint…
It seems my HA doesn’t recognize those devices as being what the blueprints are for.

Am I missing something here?
Thanks for your help!

Jan

I will look into this! Whenever I have some free time… doesn’t come that often lately.

Thanks

Hey @jan7 ,

“There are no stupid questions” Quoting someone that is surely cleverer than me.

The Z2M at the beginning of the blueprint, stands for Zigbee2MQTT. When you mention deConz, you are talking about the AddOn right?

In that case, it’s probably the cause of your issue. You need to find a blueprint compatible with that app… which doesn’t seem to exist… or I’m really bad at searching :smiley:

Sorry mate

EDIT: Nevermind am just bad… here try this template

1 Like

Aaaaaahhh!
Major revelation here!

It did never occur to me that there might be a dependency that certain blueprints only work with certain Zigbee-Usb-Sticks / their AddOn.

That solves the mystery!
Thanky you very much! And it wasn’t even your blueprint :slight_smile: Thanks!

1 Like

This dependency is solely based on the way the Addons work.

Deconz seems to be using specific events to show actions on the devices, while Z2M just relies on MQTT messages.

Since the above is the trigger to the whole automation it makes sense.