Original & Aqara Xiaomi Zigbee Sensors (contact, temp, motion, button, outlet, leak, etc)


(Colin Ho) #1258

For those who are still struggling with keeping these devices connected, i’d like to share my personal experience.

I bought 15 of these devices, all of them stayed connected on the first try except for my temperature and humidity sensors. If you had been researching pairing these, you will find there are at least 3 different recommended methods an device set up. Here is what i found worked for me.

  1. Set up device handlers on SmartThings IDE
  2. On the classic SmartThings app, press “Add a Thing” to start the pairing.
  3. On the device, hold the pairing button/pin until the LED comes on, device is now reset and in pairing mode.
  4. Wait until the device shows up on the SmartThings app, this might take up to 3-5 minutes.
  5. Confirm adding the device
  6. Check the device every hour, specifically “Last Event” time. If the time is stuck for 30 minutes or more, the connection has dropped. Remove the device and repeat from Step #2.

For some of my temp/humidity sensor, i only had to repeat these steps 3-5 times to get it to stay connected. However, i have this one that took more than 15 tries… No idea what is causing this, but just keep trying at it and eventually it will work.

The game changer for me is that i found out i didn’t need to read the catchall and create the device manually in SmartThings IDE like many had suggested. This allows me to repeat the steps in rapid succession without getting super annoyed.

Hopefully these steps can help others who are as frustrated as i was.


(Keith G) #1259

[UPDATE] “Original” Xiaomi Button DTH v1.3

For Xiaomi’s round button, model WXKG01LM

This release adds support for previously hidden functionality that is being “revealed” with firmware version 0.25.21. Because firmware 25.21 (which will be deployed soon, see here for more information) is required, this new DTH should only be used by SmartThings Hub v2 and v3 users. Let me repeat that:

NOTE: This updated DTH only works with Firmware 25.21 or higher, which is currently only available for SmartThings v2 or v3 Hubs

If you don’t have a SmartThings v2 or v3 Hub, then please use the OLD previous version of the Xiaomi Button DTH code, which has been renamed to xiaomi-button-old-firmware in the bspranger/Xiaomi GitHub repository. The direct link to the “old firmware” DTH code is here (make sure to change to this if using the GitHub Repository Integration in your IDE).

However, users of SmartThings v2 / v3 Hubs with Firmware 25.21 or higher can continue to use the same DTH code link as before:

Updated Xiaomi Button DTH code can be found here.

Main Changes

1) Added support for multi-click actions:

Action SmartThings Event Notes
Single press button 1 pushed
Hold button 1 held Event comes after button is released ~
Double-click button 2 pushed
Triple-click button 3 pushed
Quadruple-click button 4 pushed
Shizzle-click button 5 pushed 5 or more multi-click

~ Note: The default minimum time required to hold the button for the held event is 2 seconds, and this can be changed in the preference settings, found by clicking the gear icon while viewing the device in the SmartThings Classic mobile app

2) Removed preference setting to optionally send “button 2 pushed” event on hold
Because of the newly added functionality, it doesn’t make sense to allow a button hold to generate a button 2 pushed event when a double-click now does that.

3) Attempted to add support for the new Samsung Connect mobile app (UNTESTED)
This was done by adding an ocfDeviceType definition, but SmartThings has not published any documentation on adding support for the new mobile app, and currently devices using custom device handlers (like this one) are NOT yet officially supported in the new mobile app.

Detailed Change List

  • added support for multi-click actions (double, triple, quadruple, and > 5-click)
  • removed preference setting to send button 2 pushed event on hold (button hold now always sends button 1 held event)
  • added method imports to match official device handlers on GitHub/SmartThingsPublic
  • removed unneeded endpointId and profileId from device fingerprint
  • added ocfDeviceType to definition in attempt to get device handler working with new SmartThings Samsung Connect mobile app
  • added preliminary support for Device Watch
  • added initial button event for proper configuration during device pairing
  • improved followup in updated() after user saves preference settings
  • added more helpful inline comments to code
  • minor code cleanup and reorganization

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[UPDATE] Aqara Button DTH v1.4.2b BETA

For models WXKG11LM (original / new revisions) and WXKG12LM

This release fixes “broken” functionality for the original revision of Aqara Button model WXKG11LM due to a change in firmware version 0.25.21 (which will be deployed soon, see here for more information). However, this new DTH also adds multi-click functionality for the same Aqara Button model, which was not available in previous firmware versions.

Because I only own some of the model WXKG12LM Aqara Buttons, I am unable to test this updated DTH code with the original and new revisions of the model WXKG11LM buttons, so I am calling it a beta until I hear back from owners of these other two models.

NOTE: This updated DTH only works with Firmware 25.21 or higher, which is currently only available for SmartThings v2 or v3 Hubs.

If you don’t have a SmartThings v2 or v3 Hub, then please use the OLD previous version of the Aqara Button DTH code, which has been renamed to xiaomi-aqara-button-old-firmware in the bspranger/Xiaomi GitHub repository. The direct link to the “old firmware” DTH code is here (make sure to change to this new link if using the GitHub Repository Integration in your IDE).

However, users of SmartThings v2 / v3 Hubs with Firmware 25.21 or higher can continue to use the same DTH code link as before:

Updated Aqara Button DTH code can be found here.

Main Changes

1) Added support for model WXKG11LM (original revision) multi-click actions:
In addition to single-click, now double-clicks, triple-clicks, and quadruple-clicks are supported, generating a button pushed event for button 1, 2, 3, & 4, respectively. See the chart below for a comparison of the functionality of all three Aqara Button models.

2) Added button release support for models WXKG11LM (new revision) & WXKG11LM
Now these two models offer the option of using another button pushed event when the button of these two models is released after being held. See the chart below for more details about the functionality of all three Aqara Button models.

3) Attempted to add support for the new Samsung Connect mobile app (UNTESTED)
This was done by adding a ocfDeviceType definition, but SmartThings has not published any documentation on adding support for the new mobile app, and currently devices using custom device handlers (like this one) are NOT yet officially supported in the new mobile app.

Functionality Comparison Chart

Action WXKG11LM (orig) WXKG11LM (new) WXKG12LM
Single press button 1 pushed button 1 pushed button 1 pushed
Hold * button 1 held button 1 held
Double-click button 2 pushed button 2 pushed button 2 pushed
Triple-click button 3 pushed
Quadruple-click button 4 pushed
Shake button 3 pushed
Release * button 3 pushed button 4 pushed

* Notes on hold & release: Models WXKG11LM (new revision) and WXKG12LM send a “held” message when the button has been held for 400 milliseconds. This timing is hardware-based and cannot be changed, but the button can be held as long as liked. With both models a “released” message is only sent when the button is actually released.

Detailed Change List

version 1.4.2b

  • Model WXKG11LM (original revision) - all button click actions should now generate correct button X pushed events
  • Model WXKG11LM (original revision) - all button click actions should now be correctly displayed in main tile for the button viewed in the SmartThings Classic mobile app

version 1.4.1b

  • Model WXKG11LM (original revision) - fixed an issue in v1.4b where single-click messages were not correctly recognized
  • removed duplicate call to initialization() because model information is normally not available until configure() is called during pairing

version 1.4b

  • Model WXKG11LM (original revision) - added compatibility with hub firmware v25.20 and higher
  • Model WXKG11LM (original revision) - added support for multi-click actions (double-, triple-, and quadruple-click)
  • Model WXKG11LM (new revision) - added support for “button 3 pushed” event when button is released after being held
  • Model WXKG12LM - added support for “button 4 pushed” event when button is released after being held
  • added method imports to match official device handlers on GitHub/SmartThingsPublic
  • removed unneeded endpointId and profileId from device fingerprint
  • added ocfDeviceType to definition in attempt to get device handler working with new SmartThings Samsung Connect mobile app
  • added preliminary support for Device Watch
  • added incompatible device handler warning to users running firmware 24.x or earlier
  • added initial button event for proper configuration during device pairing
  • improved followup in updated() after user saves preference settings
  • added more helpful inline comments to code
  • minor code cleanup and reorganization

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[RELEASE] Aqara Wireless Smart Light Switch DTH v0.9b BETA

For 2016 & 2018 revisions of the 2-button WXKG02LM and 1-button WXKG03LM

This new device handler (DTH) was split off from the “old” Aqara Button DTH in order to best support the two revisions of the one and two-button Aqara Wireless Smart Light Switches. The code has been written so that this device handler can be used with any firmware version, but for users with hub running on Firmware 25.21 or higher, all three actions of the older 2016 revision two-button model WXKG02LM are now recognized: left, right, and both button(s) pushed.

Although this device handler is still considered in beta, it should be fully functional. All users of Aqara
Wireless Smart Switches are highly encouraged to start using this DTH immediately! You may discover you have more button actions available to make use of in Smart App automations than with the old DTH.

New Aqara Wireless Light Switch DTH code can be found here.

If were are already using the old Aqara Button DTH with a paired Aqara Wireless Light Switch, you will need to change to this new DTH. Log into your hub’s Groovy IDE, go to the “My Devices” tab, click on the name of your Aqara Wireless Light Switch in the “Display Name” column, scroll all the way down and click the “Edit” button. Click the pop-up list next to "Type: ", select “Xiaomi Aqara Wireless Light Switch”, and then click the “Update” button. You can start trying out the new DTH now!

Model WXKG03LM (1-button) Function Chart

Action 2016 revision 2018 revision
Single press button 1 pushed button 1 pushed
Hold * button 1 held
Double-click button 2 pushed

Model WXKG02LM (2-button) Function Chart

Action Side 2016 rev (old FW)* 2016 rev (new FW) 2018 revision
Single press Left button 1 pushed button 1 pushed button 1 pushed
Single press Right button 1 pushed button 2 pushed button 2 pushed
Single press Both button 1 pushed button 3 pushed button 3 pushed
Hold ** Right button 1 held
Hold ** Right button 2 held
Hold ** Right button 3 held
Double-click Left button 4 pushed
Double-click Right button 5 pushed
Double-click Both button 6 pushed

*Note about 2016 revision of 2-button model WXKG02LM: For users with SmartThings Firmware 24.x or lower, all three button actions (left/right/both pressed) pass on the same button pressed message to the DTH, so there’s no way to tell which button(s) were pressed, and so only button 1 pushed events are generated. With Firmware 25.21 or higher, the three different button actions are recognized.

**Notes about the hold function: Both of the 2018 revision of the two models send a “held” message when the button(s) have been held for 400 milliseconds. This timing is hardware-based and cannot be changed, but if the button(s) are held for more than 10-15 seconds the device will go into pairing mode, so be careful! No button release message is sent by any of the Aqara Wireless Light Switches.


[RELEASE] Xiaomi Sensors and Button (beta)
Xiaomi Zigbee Door/Window Sensor, Motion Sensor, & Smart Button Device Type [beta]
Xiaomi Zigbee Door/Window Sensor, Motion Sensor, & Smart Button Device Type [beta]
[RELEASE] Xiaomi Sensors and Button (beta)
Hub Firmware Release Notes - 25.20
(Antony Pugh) #1260

I can certainly test the 2 button DTH if needed on my V2 hub. This would be awesome and could change my mind on a couple of options I was contemplating.


(Antony Pugh) #1261

Is it worth starting a clean thread with all the changed in Function and availability.

Also will this give more reliable pairing and remain paired better? Often the information is not easy to find in such a developed thread.


(Keith G) #1262

Not sure if that’s a good idea. There’s already some confusion for users on where to look with two major threads, and a bunch of smaller ones.

No. SmartThings’ change in the newest firmware only affects certain kinds of messages received from ZigBee devices after they have been paired.

It is really important to understand that there is absolutely nothing that can be done in the device handler (DTH) code to help with pairing of Xiaomi / Aqara ZigBee devices not can it help in keeping them connected after they have been paired.

People should continue to attempt pairing Xiaomi / Aqara ZigBee devices the “normal” way, using the “Add a thing” method in the SmartThings Classic mobile app first, and only if that’s unsuccessful then use the “catchall” method.

As for Xiaomi / Aqara devices dropping their connection, the number one probable reason for this is due to other ZigBee devices on the network acting as ZigBee repeaters that are incompatible with Xiaomi / Aqara’s non-standard method of maintaining their connection.

Most ZigBee devices that are mains-powered (plugged into a wall socket) are repeaters (with the exception of some smart bulbs such as Sengled). The only ZigBee repeater devices confirmed to work with Xiaomi / Aqara devices are XBee Zigbee modules (see here for more info), IKEA Tradfri Outlet / Bulbs, and user iharyadi’s custom ZigBee multi-sensor repeater solution. Also in theory Xiaomi / Aqara’s own mains-powered devices like the Xiaomi Smart Plug or the Aqara Wired Smart Wall Switches should work as compatible repeaters, but I don’t own any myself and haven’t read enough reports by users to know for sure.

Personally, the only repeaters I use are some XBee modules and an IKEA Tradfri Outlet, and I almost never see my Xiaomi / Aqara ZigBee devices drop off the network. Full disclosure: I have moved nearly all of my home automation setup to a Hubitat hub, but the same issues with incompatible repeaters apply there as well. However, I am doing frequent testing with my 40+ Xiaomi / Aqara devices on the SmartThings platform in order to improve and update the SmartThings device handlers (DTHs).


(Keith G) #1263

[UPDATE] Aqara Button DTH v1.4b BETA

(For models WXKG11LM (original / new revisions) and WXKG12LM

This release fixes “broken” functionality for the original revision of Aqara Button model WXKG11LM due to a change in firmware version 0.25.21 (which will be deployed soon, see here for more information). However, this new DTH also adds multi-click functionality for the same Aqara Button model, which was not available in previous firmware versions.

Please see this post for full details about the updated Xiaomi Button DTH and Aqara Button DTH and the links to the updated code.


(Antony Pugh) #1264

Fair enough just sometimes hard to find info on which DTH exist for each bit of kit. its almost like a table of supported devices and functions with which handlers should be used. There are so many Xiaomi devices now its getting large.

Maybe a table added to the first post of all the supported devices and last update? Just to help people rather than search randomly through 1200 posts. Something like this (data is no right!) Maybe to make it easier 2 tables. one Pre and one Post FW change.

Device Revision DTH Name Last Updated Supported Unsupported
Aqara Button WXKG11LM Aqara Button DTH v1.4b BETA March 6 2019 Single Click, Multi Click, Hold ST Hub FW pre 0.25.20
Aqara 2 Button Light Switch XXXXXXXX Aqara 2 Button Wall Neutral/Batt BETA Coming Soon Single Click, Left and Right Buttons, Dual button Press ST Hub FW pre 0.25.20
Aqara 2 Button Light Switch XXXXXXXX Aqara 2 Button Wall Neutral/Batt Limited 02 Feb 2017 Single Click, Right Button Physical, Left button In app Only ST Hub FW Post 0.25.20, Left Button Acknowledgment, Dual Button Press

Good to know about the changes. and the repeater functions. so actually the more powered Xiaomi devices the more likely these will act as a repeater instead of any other item. I have had less issues lately with drop outs but maybe as I now have a lot more Xiaomi devices in the house. the powered ones are never an issue.


(Keith G) #1265

[UPDATE] Aqara Button DTH v1.4.1b BETA

(For models WXKG11LM (original / new revisions) and WXKG12LM

This release fixes an issue in the v1.4b code with single-click not working correctly for the original revision of the model WXKG11LM button.

Please see this post for full details about the updated Xiaomi Button DTH and Aqara Button DTH and the links to the updated code.


(Keith G) #1266

You mean like the table I made in this post?

That amount of information all nicely organized and kept up-to-date is something that requires time and work. If I didn’t have a job and a family giving me all the time in the world then I would be able to get right to doing that. But my time is limited, plus for over a year I’ve been making DTH updates and helping out with issues and questions all for free.

I will see what I can do, but considering the effort required and I’m in the middle of working on a bunch of Xiaomi / Aqrara driver code updates on two home automation platforms, I can’t make any promises.


(Antony Pugh) #1267

Let me see what I can put together to save you time. Then if you can update it and add it if you get time. I appreciate you do this for free and happy to help out where Poss.


(Keith G) #1268

[UPDATE] Aqara Button DTH v1.4.2b BETA

(For models WXKG11LM (original / new revisions) and WXKG12LM

This release fixes two issues in the v1.4.1b code that only affected the original revision of the model WXKG11LM Aqara Button:

  1. button X pushed events were not being correctly generated
  2. Button clicks were not being displayed in the main tile when viewing the button in the Classic SmarThings mobile app

Please see this post for full details about the updated Xiaomi Button DTH and Aqara Button DTH and the links to the updated code.



Thanks, though I should point out that a table with 6 columns like your example is probably best suited for an online spreadsheet (such as a Google Sheet, which I’ve already started).

If you have a Google account, then you can copy my Google Sheet spreadsheet chart to make your own copy that you can then edit. Here’s the link:


(Keith G) #1269

[RELEASE] Aqara Wireless Smart Light Switch DTH v0.9b BETA

For 2016 & 2018 revisions of the 2-button WXKG02LM and 1-button WXKG03LM

This new device handler (DTH) was split off from the “old” Aqara Button DTH in order to best support the two revisions of the one and two-button Aqara Wireless Smart Light Switches. The code has been written so that this device handler can be used with any firmware version, but for users with hub running on Firmware 25.21 or newer, all three actions of the older 2016 revision two-button model WXKG02LM are now recognized: left, right, and both button(s) pushed.

Please see this post for full details about this new device handler and the link to the DTH code.


(Nino Matarazzo) #1270

Hello all,

I am currently using the Aqara motion sensor to turn on smart lights in my home, this is currently done by motion between the hours of Sunset and Sunrise (+/-30 mins), I was hoping to use the illumination feature to replace this however I have the message, ‘Beta feature currently not supported for local execution’ is there anyway to get this feature working?


(Keith G) #1271

I believe that error is created by whatever Smart App you are using for the motion -> lights on automation. All non-official custom device handlers will not execute locally. What Smart App are you using? Can you provide a screen shot of the error?

Please note, however, that using the illumination reports from an Aqara Motion Sensor for this purpose may not work as expected.

The reason for this is that the Aqara Motion Sensor only sends illumination report messages when motion is detected, and the message for illumination is sent just milliseconds before the motion detected message, meaning the SmartApp may still see the previous illumination value to make its decision to turn on the lights.

For example, you set the automation to turn on lights if motion is detected and the illumination value is below 15. Here’s what could happen:

14:00 The motion sensor detects motion and reads illuminance at 25 lux
17:40 The ambient light level goes below 15, but nothing happens because the motion sensor has not detected any motion since 14:00
18:30 The motion sensor detects motion and reads illuminance at 10 lux, but the Smart App does not turn on the lights because it still sees the previous illuminance value of 25
18:31 The motion sensor detects motion again and reads illuminance at 10 lux, and the Smart App finally turns on the lights


(Nino Matarazzo) #1272

Thanks for the reply.

I am using the feature within SmartThings app.


(Keith G) #1273

I did a search on the SmartThings forums here and see that the message ‘Beta feature currently not supported for local execution’ is from the Smart Lighting app. It is not related to Xiaomi / Aqara devices. It will appear for any illuminance capable device.

I think all the message is saying is that if you use illuminance as a “restriction” in the “More options” section then the app will not run locally, but rather in the cloud. It should still work, however.

If you have tried setting it up and it’s not working with the Aqara Motion Sensor, then that is because of the reason I mentioned before:

To repeat: The Aqara Motion Sensor only sends illumination reports when it detects motion. It does not send illumination reports every xx minutes. Because of the order of the illumination and motion detected messages, any automation using illumination levels along with motion detected to decide whether an action should be taken may not work reliably.


#1274

I just had to delete and re-pair each of my half-dozen Aqara Door/Window sensors, as none were communicating with the Smarthings Hub. All other devices (Z-Wave deadbolts, Zigbee lightbulbs, and Aquara Temp/Humidity sensors) were fine. I could not get the device to repair without first deleting and then re-adding. Upon re-adding, two of the sensors functioned, but reported bogus -519% battery charge, so a toggle of the “replaced battery” fixed the error, but only after exiting and re-entering the android app. Is there a better approach to this scenario?


#1275

Just ordered two WXKG12LM buttons. I will try to use them as front door and back door doorbells. Let’s see how they will work. Just have to wait 2-3 weeks to get them from China. They cost 10€ piece so very cheap I would say.


(Keith G) #1276

No, not from what you’ve detailed.

Let’s separate your issues first, however, because they are completely unrelated.

Aqara Door/Window Sensors not communicating with hub
When this happens, it’s because of one of two reasons, either

  1. their ZigBee network connection was interrupted, or
  2. you are using ZigBee repeater devices that Xiaomi/Aqara devices are incompatible with.

In both cases, Aqara / Xiaomi devices won’t rejoin the ZigBee network when requested by the hub because they are not 100% compliant with ZigBee protocol.

There are a whole host of things that can lead to reason 1, search for ZigBee interference / signal strength, so I’ll focus on #2. Any mains-powered ZigBee device, with the exception of some ZigBee smart bulbs (e.g., Sengled), is very likely a repeater. A ZigBee repeater helps to increase the range of a ZigBee mesh network by acting like a WiFi extender: ZigBee end devices can connect to a repeater that is closer with better signal strength instead of directly to the hub.

The origin of the problem in this case is that most ZigBee repeater devices have a check-in timeout period of time that is shorter than the 50-60 minute regular check-in time of Xiaomi / Aqara devices, and when those devices finally do try to check in and the repeater asks them to follow the normal ZigBee protocol of leaving and rejoining the network, Xiaomi / Aqara devices never rejoin.

There is no way to reprogram the Xiaomi / Aqara devices, and there is no way to easily affect whether end devices choose to connect to a particular repeater device except to remove that repeater device from the network completely.

A handful of repeater devices have been confirmed to work with Xiaomi / Aqara devices: XBee Zigbee modules (see here for more info), IKEA Tradfri Outlet / Bulbs, and user iharyadi’s custom ZigBee multi-sensor repeater solution . Also in theory Xiaomi / Aqara’s own mains-powered devices like the Xiaomi Smart Plug or the Aqara Wired Smart Wall Switches should work as compatible repeaters, but I don’t own any myself and haven’t read enough reports by users to know for sure.

Do you use any mains-powered ZigBee devices? If yes, I would highly suspect them as the reason that your Aqara Door/Window sensors dropped off the network.

Incorrect battery percentage reported

Most of the Xiaomi / Aqara device handlers include some code designed to retrieve battery voltage data that is sent when the device’s reset button is short-pressed.

Changes in recent SmartThings firmware updates led to some messages that don’t contain any battery voltage data being formatted differently, and as a result this code pulls out an incorrect voltage value that gets reported as an out-of-bounds percentage.

This is absolutely nothing to be alarmed about, and as soon as the Aqara / Xiaomi device performs its regular 50-60 minute check-in that includes correct battery voltage data, the percentage value will appear as normal.

I am working on a method to filter out the messages that don’t contain battery voltage data, but as I work on the device handlers in my free time, and my free time is limited, and I am not paid to do any of this work, updates to all the device handlers with a fix won’t happen immediately.

I hope this information is useful, and I’m sorry for any inconvenience. Just please keep in mind that any dropped connections of Aqara / Xiaomi devices are completely unrelated to the device handlers.