I have recently purchased a few Xiaomi Aqara Zigbee buttons (WXKG11LM) and am struggling to set them up properly to trigger some of my automations.
They are working fine with my Zigbee2MQTT dongle on a Pi3 and show up as sensors in HA.
When I push the button the state changes to single, double, triple or quadruple - but then it keeps that state for about 50 minutes.
So if I want to use the button to toggle the light on/off with a single key press, I either need to do a multi key press in between - or wait 50 minutes
I found that if I set the state of the button manually in the /dev-state, I can use a single click straight away again.
I don’t have the exact same button as you, but I do have another Xiaomi Aqara switch. If it works the same way, the way you want to trigger automatons is not by looking at state changes, but by listening to events. In my case, since my switch has two buttons, the automation trigger in the front end looks like this:
If I want to trigger a different automation with a double click, that automation will listen for a “left_double” zha_event. If I want to use another physical switch, I change device_ieee to the one of the other switch, etc.
To check what these values are for your particular switch, go to the Events page under developer tools in the front end, subscribe to “zha_event” (without quotes), and press the switch. Good luck!
Sorry, missed that you’re using MQTT. For me it’s a zigbee switch, connected via the zha component and HUSBZB-1 radio plugged into RPi 3B+. It shows up as several sensors (binary and others).
Maybe you need to listen for mqtt triggers instead of sensor changes then? (like described on this page)
The tricky part was the sequence in the last four lines; everything else I tried, e.g. escaping the " with \ threw errors in the config check. This seems to work fine now and I can use the same sequence at the end of every automation that is triggered by one of these nifty little buttons.
FYI - I found the solution here, provided by @NotoriousBDG: