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

[UPDATE] Xiaomi Smart Plug DTH v1.1

(For Xiaomi’s ZigBee Outlet model ZNCZ02LM)

This release adds power / energy metering support, with all thanks and credit going to GitHub user @mike-debney.

The updated DTH code can be copied directly from here . Please note that I have not been able to test the new code changes because I do not own a Xiaomi Smart Plug myself. Any feedback from Xiaomi Smart Plug users would be greatly appreciated!

Changes :

  • added parsing of wattage power load messages from the outlet
  • added support to create power load events for use in SmartApps
  • added parsing of wattage power metering messages from the outlet
  • added support to create power metering events for use in SmartApps
  • added device power and energy meter value display tiles

Screenshot

1 Like

Can I ask a real noob question. Have a aqara neutral single wired switch and johndoyle is working fine but temp doesn’t update and new connect app doesn’t show on or off. I have changed the DH to zigbee switch so the light on off works from front page but no temp. Now I would like the temp but prefer the on/off state working better. Can I modify the ZigBee switch code to show temp?

Instead, try adding ocfDeviceType: "oic.d.switch" and genericHandler: "Zigbee" to the definition() line in John Doyle’s DTH:

In other words, change line 15 from

definition (name: "Xiaomi Zigbee Mains Toggle Switch", namespace: "johndoyle", author: "John Doyle") {

to

definition (name: "Xiaomi Zigbee Mains Toggle Switch", namespace: "johndoyle", author: "John Doyle", ocfDeviceType: "oic.d.switch", genericHandler: "Zigbee") {

The ocfDeviceType definition is used by the new SmartThings Samsung Connect mobile app, but unfortunately SmartThings has not provided any documentation on how to integrate it into custom DTHs yet.

As for genericHandler, this is something very new with absolutely no explanations, but it has been added to SmartThings’ official ZigBee-based device DTHs so it’s worth a try.

Did t work I’m afraid. I’ll stick with the normal ZigBee switch. Thanks any way

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.

4 Likes

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

For Xiaomi’s round button, model WXKG01LM

button
This release adds support for previously hidden functionality that has been “revealed” with firmware version 25.26. Because Hub Firmware 25.26 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 Hub Firmware 25.26 or higher, which is currently only available for SmartThings v2 or v3 Hubs

The updated Xiaomi Button DTH code can be found here.

NOTE: After updating to the new DTH, open the preference settings for your button in the SmartThings “Classic” Mobile App and then press “Save”. This will set up the correct increased number of buttons available for automations.

If you don’t have a SmartThings v2 or v3 Hub:

Please use the OLD previous version of the Xiaomi Button DTH code, which has been renamed to xiaomi-button-old-firmware. 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).

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

This updated and improved device handler code is open source and free.
But if it has helped you, a coffee / beer donation is always very much appreciated!
PayPal: 37544ab59e07a5c90719f07501453cae3ed7b043 Venmo: @KeithPG

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

[UPDATE] Aqara Button DTH v1.4.3

For models WXKG11LM (original / new revisions) and WXKG12LM

aqarabutton
This release fixes “broken” functionality for the original revision of Aqara Button model WXKG11LM due to a change in Hub Firmware version 25.26. 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 Hub Firmware 25.26 or higher, which is currently only available for SmartThings v2 or v3 Hubs

The updated Aqara Button DTH code can be found here.

NOTE: After updating to the new DTH, open the preference settings for your button in the SmartThings “Classic” Mobile App and then press “Save”. This will set up the correct increased number of buttons available for automations.

If you don’t have a SmartThings v2 or v3 Hub:

Please use the OLD previous version of the Aqara Button DTH code, which has been renamed to xiaomi-aqara-button-old-firmware. 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).

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.

For instructions on how to check exactly which model and revision of Aqara Button you have, please see this post.

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.3

  • fixed issue with erroneous battery level events from catchall: messages that don’t actually contain battery voltage data

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

This updated and improved device handler code is open source and free.
But if it has helped you, a coffee / beer donation is always very much appreciated!!
PayPal: 37544ab59e07a5c90719f07501453cae3ed7b043 Venmo: @KeithPG

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

[RELEASE] Aqara Wireless Smart Light Switch DTH v0.9.2

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


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 Hub Firmware 25.26 or higher, all three actions of the older 2016 revision two-button model WXKG02LM are now recognized: left, right, and both button(s) pushed.

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.

The new Aqara Wireless Light Switch DTH code can be found here.

If you 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 Switch”, and then click the “Update” button. IMPORTANT: After updating to the new DTH, open the preference settings for your button in the SmartThings “Classic” Mobile App and then press “Save”. This will check your button model and set up the correct number of buttons available for automations.

For instructions on how to check which revision of Aqara Wireless Light Switch you have, please see this post.

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.

Detailed Change List

version 1.4.1b

  • Initial release

version 1.4.2

  • changed device definition name to get GitHub Integration working correctly

This new improved device handler code is open source and free.
But if it has helped you, a coffee / beer donation is always very much appreciated!
PayPal: 37544ab59e07a5c90719f07501453cae3ed7b043 Venmo: @KeithPG

18 Likes

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.

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.

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. Also the DTH cannot 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).

7 Likes

[UPDATE] Aqara Button DTH v1.4b BETA

For models WXKG11LM (original / new revisions) and WXKG12LM

aqarabutton
This release fixes “broken” functionality for the original revision of Aqara Button model WXKG11LM due to a change in Hub Firmware version 0.25.26. 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.

4 Likes

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.

[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.

1 Like

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.

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.

1 Like

[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:

[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.

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?

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

Thanks for the reply.

I am using the feature within SmartThings app.

image

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.