[OBSOLETE] Original Xiaomi Aqara Smart Wireless Switch (Aqara Button)

Xiaomi / Aqara devices require the use of a custom device handler (also known as “DH” or “DTH”). Basically think of it as a device driver.

My post right before yours links to post in another thread dedicated to Xiaomi / Aqara devices that is a recent update of device handlers for a number of different Xiaomi / Aqara button models.

You will need to log into what’s known as the SmartThings Groovy IDE. Click on the Locations tab, choose your locations, and then click the My Device Handlers tab where you can add the corresponding custom device handler for your button. This is done by creating a new device handler, copy-pasting the code, and clicking the [create] button at the bottom of the web page. The code to copy from will be found in the corresponding link of the post I mention above.

Then since you’ve already added the button and it’s showing up as a “Thing” (meaning no device handler has been assigned), you need to assign the correct device handler to it. This is also done while logged into the SmartThings Groovy IDE, in the My Devices tab. Find the button, click on its name to view its details, scroll down and click [Edit], and in the pop-up menu next to Type: (which refers to “Device Type”, the name given in each device handler), find the correct device name, for example “Xiaomi Aqara Button”, which will be down near the bottom of the list because that’s where custom device types are found. Then save, and you can start using the button in the “classic” mobile app (Xiaomi / Aqara devices aren’t fully supported in the new Samsung Connect mobile app).


Thanks Veeceeoh! I already used the code to create the DTH before adding the button through the classic app. Just checked into the IDE and the button already has the type Xiaomi Zigbee Aqara Button AQ2 maybe I don’t have the right DTH code?

Just saw your new code, added it to my handler and assigne it to the button, i’ll test it tonight when . i’m back home

thanks a lot

HI, thanks, I removed the old one and the device handler, added your code for my model WXKG11LM. Classic app found it right away. Went to change the type. But it always shows in Released… even when i press the button :frowning: Any idea?


The display of the button status is a kind of “hack” that I came up with to make the UI for the button device handlers more useful. As such, due to the nature of SmartThings executing code “in the cloud”, the display of the button status may be slow or not display at all. However, the actually button 1 pushed event will always work (unless ST is down, which does happen).

So… you should double-check whether a pushed event occurs by looking at the Recently tab for the button while viewing it in the ST “Classic” app.

If you don’t see the correct events occurring there, then I can help with live logging output. You’d want to enable the display of “info” and “debug” log messages in the preference settings for the button (by clicking the gear icon while viewing the button in the ST “Classic” app). The Live Logging settings toggles are at the bottom, so scroll down:

After pressing [save] then open up the SmartThings Groovy IDE for your hub and change to the Live Logging tab so that log messages can be viewed while pressing / holding / etc. the button. That’s what I’d need to see if events aren’t occurring.


I only see this, the button does not make the smart light works… only if i press it in the classic app but not the button…


Whoa! The message in that log output looks nothing like what I expect to see from any Xiaomi / Aqara Button!

That matches a kind of message I expect from the Aqara Vibration Sensor, model DJT11LM.

Maybe you have a new variation of the Aqara Button?

Can you please confirm the model of your button and perhaps post a photo of the front/back of it?

uhm interesting cause you know i have a aquara motion sensor also that i tried to configure in the past that is in the drawer, could it be that it interfered with the adding of the button? i’ll remove the battery from the motion sensor, remove the button and tried again the process of pairing

and i’ll let you know


No it wouldn’t interfere. That message is from one specific device only, the one you have named “Office Button”. And that message would never be produced by an Aqara motion sensor either. The only Aqara device that sends messages on cluster: 0101 and attrId: 0505 is the Vibration Sensor.

Can you take a screenshot of the device details page in your hub’s IDE? It will look like this:

uhmm it worked… now i put back the battery in it and would try to make it work since the button is working great now. Do you have a DTH for this too?


Ah ha! That is the Vibration Sensor, not a button. The Aqara button looks like this:

So you must have confused your Aqara Vibration Sensor for the button. Some sellers call it a “Motion Sensor” but that is confusing because there is already a PIR (“person in room”) motion sensor from Aqara. So I only call it the Vibration Sensor.

Yes, I have made a SmartThings device handler for the Aqara Vibration Sensor. The latest version is v0.92b, but the best explanation of how to use it is in this post:

PLEASE NOTE: The feature to change the sensitivity level does not work yet. I have got it working for another similar hub, called Hubitat Elevation, so I have been looking at a method to get the feature working in the SmartThings device handler.

no non I did not confuse them but after i removed everyting and add id again, the button works! i am now trying to make this vibration sensor work

thanks again for your kind support

Hi Guys,

I have a weird problem. I’m using bspranger’s DTH for Xiaomi Zigbee Button - Model WXKG01LM.
It pairs well and reports the correct status (Single click, double click, held) but the aim for me to get this is to be able to control Alexa routines. For some reason, Alexa is not discovering this device.

I’ve successfully paired the Xiaomi Motion Sensors and Door/Window Sensors, and both were discovered by Alexa.

Any idea what could be wrong? I’m pulling my hair out trying to figure it out (I’m not a tech guy…)


Hi, Justin

I’m having the exact same issue. It’s like Alexa cannot detect when certain drivers are used in SmartThings.

If you change the DTH in ST to say “SmartSense Button”, alexa finds it right away, but this driver doesn’t work in SmartThings with the Xiaomi button.

Not sure where to go from here.