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

Hi,

I added a couple of Aqara temp sensors and a leak sensor.
Paired and working well with smartthings classic app.

However when using the new Smartthings app, these sensors are inaccessible. It just says Can’t connect to device. Check device and try again.

Other devices work well in the new Smartthings app. Hue lighting system and Logitech Harmony.
I don’t know if it’s relevant or not, but another thing I noticed was initially the Add Manually option allowed many different device types to be added in the new App. However now that I had added my stuff using the classic app, I can only add some simple devices like TV, AV, Washer etc. No hubs, sensor or other components All gone.

Any idea?

Thanks

[BETA] Xiaomi Aqara Button SmartThings DTH v1.3b

I have updated the Aqara Button device handler to add support for the new revision of model WXKG11LM. While working on it, I also realized that I could add support for the hold and double-click functions of the Single-Button Aqara Wireless Smart Light Switch (model WXKG03LM).

The new beta DTH code can be copied directly from here.
NOTE: This DTH needs testing before it can be considered a full release.

Here are some handy charts that show how different types of button actions are passed on as SmartThings events to be used by SmartApps for automations:

Aqara Button - Model WXKG11LM (original revision)

Action Event Button #
Single-click pushed 1

Note: Although the hardware also supports double-, triple-, and quadruple- click messages, SmartThings only sees single-clicks.

Aqara Button - Model WXKG11LM (new revision)

Action Event Button #
Single-click pushed 1
Hold held 1
Double-click doubleTapped 1
Release lastReleasedCoRE n/a (see note below)

Notes: A release message is sent when the button is released after being held, which results in a lastReleasedCoRE event, which can be used by WebCoRE users (SmartThings doesn’t support a “released” event in its button capability implementation). I don’t own this model, but I assume the hardware button held message is sent after 400ms like with Model WXKG12LM.

Aqara Button - Model WXKG12LM

Action Event Button #
Single-click pushed 1
Hold held 1
Double-click doubleTapped 1
Release lastReleasedCoRE n/a (see note below)
Shake pushed 2

Notes: A release message is sent when the button is released after being held, which results in a lastReleasedCoRE event, which can be used by WebCoRE users (SmartThings doesn’t support a “released” event in its button capability implementation). The hardware button held message is sent after the button has been held for 400ms.

Aqara Button - Model WXKG03LM (original revision)

Action Event Button #
Single-click pushed 1

1-button Aqara Wireless Smart Light Switch - Model WXKG03LM (new revision)

Action Event Button #
Single-click pushed 1
Hold held 1
Double-click pushed 2

Notes: The hardware button held message is sent after the button has been held for 400ms. However, holding the button for more than 15-20 seconds puts the device into pairing mode.

2-button Aqara Wireless Smart Light Switch - Model WXKG02LM (original revision)

Action Event Button #
Press left button pushed 1
Press right button pushed 1
Press both buttons pushed 1

Note: The 2-button Aqara Smart Light Switch model WXKG02LM (original revision) is only recognized as ONE button. This is because the SmartThings API ignores the data that helps distinguish between left, right, or both-button presses.

Change List

  • added support for new revision of the model WXKG11LM Aqara Button, which appears as ZigBee model lumi.remote.b1acn01
  • added support with hold and double-click functionality for 1-button Aqara Wireless Smart Light Switch (model WXKG03LM - new revision), which appears as ZigBee model lumi.remote.b186acn01
  • added new function call to determine model of Aqara button when paired, display it in live logging, and set correct number of buttons for SmartThings SmartApps to make use of
  • minor formatting and comment text revisions
4 Likes

Please try out my new beta release that added compatibility for the new revision of the 11LM Aqara Button.


Custom device handlers, like all of the ones for Xiaomi devices, are not yet officially supported in the new SmartThings Mobile App.

Some users have attempted to add the code needed for making custom device handlers work in the new mobile app, but I have no plans to try to hack together a solution until Samsung/SmartThings has published official developer documentation on this. Sorry for any inconvenience!

The 2 button wall switched from Xiaomi. Is it a technical impossibility for Smartthings to add the coding to allow the button to be scene properly without them redesigning it all. or is it just they haven’t don it?

Does that make sense? As the Xiaomi market is so large to most Smart users now. has anyone thought of trying to start something to get official integration?

Got it, thanks.
I hope they don’t plan on phasing out the classic app then before officially supporting the custom handlers.

The technical explanation of the exact problem going on here is that SmartThings does not recognize messages sent by devices on different endpoints using the same cluster. The ZigBee specification uses clusters as a way to group different types of message data, such as the “on/off” cluster 0x0006, and endpoints are intended as a way to differentiate between different applications or sets of functions assigned to a device. Sometimes device manufacturers use different endpoints assigned to one function of a device, however, which is true for a number of Xiaomi devices.

I’ve been mentioning this issue for a while because it also affects the Xiaomi “original” and Aqara WXKG11LM (original revision) buttons. Used with SmartThings, you’re missing out on hold, double-click, etc. messages that never get sent through:

If you search the ST forums, you will find that SmartThings’ lack of support for ZigBee multiple endpoint messages is a well-known issue, and there is a far-less-than-ideal suggested workaround. From this thread:

This suggested workaround does not work for Xiaomi devices, because they ignore read attribute commands on the on/off cluster. So SmartThings can’t “ask” them what kind of button press just happened.

If you read through the rest of the thread I linked to above, you see that the problem for the SmartThings engineers is that adding in Zigbee multiple endpoint message support would break things for just about everyone. This is because it would add information to the parsed incoming message data that device handlers aren’t expecting.

Honestly I’m not sure if this will ever get addressed, because it’s been a known issue for some years now, which is one of a number of reasons I’ve moved my home automation setup mostly off of the SmartThings platform.

Is the Xiaomi market large to SmartThings? I have no evidence either way.

The bottom line is that Xiaomi’s ZigBee devices do not conform 100% to the ZigBee specification, resulting in them being dropped off of non-Xiaomi gateway hubs’ networks in some circumstances. So I have a lot of difficulty seeing why Samsung/SmartThings would ever consider officially supporting Xiaomi home automation devices.

2 Likes

Thanks for looking in to this…!! :+1:
I have just tested the new DH on a WXKG03LM, but it does not seem to recognize button 2 or held events - i only get “Button 1 was pushed” in live logging… :thinking:

I if go to the buttons settings an enable the “Display debug log messages” i get the following in live logging, when hitting save:

0e4cf061-dffc-4d03-999f-43f9eb9ff913 20.58.27: debug Update detected: DeviceUpdated b28665f0-e242-4662-baf3-94adcf088185

b28665f0-e242-4662-baf3-94adcf088185 20.58.27: error java.lang.NullPointerException: Cannot invoke method startsWith() on null object @line 359 (setNumButtons)

b28665f0-e242-4662-baf3-94adcf088185 20.58.27: info Xiaomi test: Updating preference settings

b28665f0-e242-4662-baf3-94adcf088185 20.58.27: error java.lang.NullPointerException: Cannot invoke method startsWith() on null object @line 359 (setNumButtons)

b28665f0-e242-4662-baf3-94adcf088185 20.58.27: info Xiaomi test: Updating preference settings

Don’t know if you can use this info for debugging?
Let me know if i should send you other info to help out… :slight_smile:

Edit:
Maybe found the error myself - no Zigbee Model ID - could this be the reason, and how do i fix it? (the button works fine as a 1 button device)

Yes, that’s what’s causing the errors you saw, but they are only related to initializing the number of buttons available to SmartThings SmartApps.

The reason why the ZigBee model ID isn’t there is probably because you used the “catchall” method to pair your WXKG03LM Aqara switch. I had the same experience while testing my 2-button WXKG02LM model, and I will need to add code to catch when the ZigBee model ID is blank. For now, those errors aren’t hurting anything, however.

But with the double-click and hold events, since I don’t have the WXKG03LM model, would you mind copying the log output you see when you try those actions with the switch? That would help me to know what’s going wrong, or that perhaps SmartThings just isn’t recognizing the messages for double-click / hold actions.

Also possible - I added those additional functions based on reports from a Hubitat hub user, so that I could update the Hubitat device handler for Aqara buttons. But like with the new revision of the WXKG11LM Aqara Button, there might be new revisions of the Aqara Wireless Smart Wall Switches. So you may just have an old revision which only has a single-click function.

Wouldn’t you know… :astonished:
Just deleted the button from ST, brewed a cup of coffee and prepared myself for a long haul to get it repaired…
It repaired at my second attempt and was assigned the DH automatically…!! First time i have ever paired a WXKG03LM without using the Catchall method… :muscle:

So the live logging show this, both with single press, double press and hold:

373d0d8b-bd1b-4aa4-bb8d-ba842c451b0c 22.26.05: debug Aqara Switch WXKG03LM: Creating event [name:button, value:pushed, data:[buttonNumber:1], descriptionText:Aqara Switch WXKG03LM was pushed, isStateChange:true]

373d0d8b-bd1b-4aa4-bb8d-ba842c451b0c 22.26.05: debug Aqara Switch WXKG03LM: Setting Last Pressed to current date/time

373d0d8b-bd1b-4aa4-bb8d-ba842c451b0c 22.26.05: info Aqara Switch WXKG03LM was pushed (Button 1 pushed)

373d0d8b-bd1b-4aa4-bb8d-ba842c451b0c 22.26.05: debug Aqara Switch WXKG03LM: Setting Last pressed to current date/time

373d0d8b-bd1b-4aa4-bb8d-ba842c451b0c 22.26.05: debug Aqara Switch WXKG03LM: Parsing ‘on/off: 1’

Is this what you asked for?

1 Like

If you see those same set of messages that start with “Parsing ‘on/off: 1’” then that means either there are two revisions of the WXKG03LM or SmartThings isn’t recognizing the double-click and hold messages. But it’s more likely there are two revisions of the WXKG03LM because the Hubitat user who helped me with log messages saw the single/double-click and hold messages sent from cluster 0012, but your log messages show on/off: which is cluster 0006 - totally different.

It would really help if we knew of more owners of the 1-button WXKG03LM Aqara Wall switch to check what log output they see.

A few weeks ago all of a sudden, a bunch of my Xiaomi Aqara devices dropped off the network. I cannot get them to reconnect. Anyone else having this issue. Do I need to remove them from the hub? I would like to avoid that.

I have been having the same issue for the past two weeks or more with some of my xiaomi devices. I can’t get them to stay connected for more than couple hours anymore and nothing changed in my setup so I’m thinking it has to do with the latest hub firmware update st pushed :man_facepalming:

1 Like

Have just added this DTH and changed my button to use it. Pulled this from the log:

14:05:00: info Button 3 was released
14:04:59: info Button 3 was held (Button 1 held)
14:04:55: info Button 3 was double-clicked (Button 2 pushed)
14:04:48: info Button 3 was single-clicked (Button 1 pushed)

I’m about to try a few things in webcore.
Anything in particular you want testing?

How do I use the custom events? I can only see pushed or held in webcore.

I have two of these. Since changing to the new DTH is see this in the events.

2018-11-04 2:59:08.823 PM GMT
moments ago
DEVICE button held Lounge Wireless was held
2018-11-04 2:58:26.405 PM GMT
moments ago
DEVICE button pushed Lounge Wireless was double-clicked
2018-11-04 2:58:19.849 PM GMT
moments ago
DEVICE button pushed Lounge Wireless was single-clicked
2018-11-04 2:58:12.791 PM GMT
moments ago
DEVICE numberOfButtons 3 Lounge Wireless number of buttons is 3

Thanks for that

Thanks for that.

Interesting read. Shame they can’t choose how the data is processed based on a profile of the device.

[BETA] Xiaomi Aqara Button SmartThings DTH v1.3.1b

With @mikejclark reporting back on his 1-button Aqara Wireless Smart Wall Switch (model WXKG03LM), it appears that there are actually two revisions of this product: One which only sends a “button pushed” message, and the other which has single-click, double-click, and held functionality. From his report, it appears my update to the Aqara button DTH is working as expected, but I’ve added comments regarding the different revision models.

Also, I decided to add lastHeld and lastHeldCoRE custom attributes for events that can be used with WebCoRE.

The updated DTH code can be copied directly from here.

Changes

  • added custom attributes lastHeld (with human-readable date/time stamp) and lastHeldCoRE (with UNIX Epoch date/time stamp) which can be utilized in WebCoRE
  • added comments in header section related to original/new revisions of 1-button Aqara Wireless Smart Wall Switch model WXKG03LM, and the 2-button WXKG02LM
  • added comments specific to new revision of WXKG03LM in button press parsing function
  • other minor fixes

Thanks for reporting back on what you’re seeing with your model WXKG03LM. So it appears there are two revisions of this model!

In your WebCoRE screenshot it looks like you are using button events to compare values to. The custom events are based on custom attributes, not on button events.

Look for these: lastHeldCoRE, lastPressedCoRE, and lastReleasedCoRE. When the events on these custom attributes happen, they are set to not display in the events list, because it would just clutter the events list display in the SmartThings (Classic) Mobile App. You can confirm they are happening by turning on debug message logging in the preference settings for the button in the Mobile App.

It would be super helpful to make sure your model WXKG03LM button doesn’t send any message when you release the button after holding it (which some of the other Aqara buttons do). The way to check this is turn on debug message logging and then look for a message after the “Lounge Wireless was held” message which includes “Parsing” but without being followed by “Creating event”.

The other thing I’m curious about is whether the two different models of the WXKG03LM button report the same ZigBee model information. This can be found in the “Data” section of the Device page for your button in the IDE (My Devices tab → click on the name of your button), like this:

Thanks for explaining, I’ll give this a go.

Not really sure what this means. Do I need to enable the logging first?
I held the button first, followed by a single push a short time after. Does this help?


Looks like I have two versions of this switch. The first shown here is for the logs above.
image

image

It looks like the latest contact, switch, water and button from Lumi (manufacturer of Xiaomi Mi and Aqara) are zigbee 3.0 certified. Which means in theory they will work with standard zigbee communication

3 Likes

In theory!

However, looking through the certification documentation for just the new Door & Window Sensor, this appears to be the good news we’d want to see from Xiaomi moving forward:

So from what I understand, this and the other new ZigBee 3.0 certified Aqara devices will attempt to rejoin a mesh network that it was previously on, which is something all previous Xiaomi devices fail to do. Even after searching through some of the ZigBee Alliance’s certification documentation, I’m not sure what the “ZLT3” designation refers to, but the “M” means “Mandatory”, and “Yes” of course means that function is supported. My hope is that the new Aqara devices will also automatically rejoin the network of a ZigBee 2.1 hub.

Interestingly this certification process has been going on since 2015, and thankfully all of the ZigBee 3.0 certified Aqara devices have new model numbers, and the new product names listed on the ZigBee Certification website end with “T1”, except for the “Wall Switch (with Neutral, Double Rocker) S2”. I say “thankfully”, because recently Xiaomi has released new revisions of some of their Aqara ZigBee products under existing model numbers, but with different hardware feature sets.

Because Xiaomi’s website hasn’t been updated to display the new “T1” & “S2” product lineups, and there are multiple older models with the same external case but different features, I expect things to be a confusing mess for people looking to buy Xiaomi devices. It’s also a complete mess in terms of supporting all of the models / variants in SmartThings device handlers. With that in mind, I am building a spreadsheet to make sense of all of the different models / revisions of Xiaomi’s ZigBee smart home devices.

Here’s a preview:

Xiaomi Device Name Device Type Model / SKU Zigbee Model Certification
Aqara Cube Controller Multi-function Controller MFKZQ01LM lumi.sensor_cube
Original Door and Window Sensor Magnetic Contact Sensor MCCGQ01LM lumi.sensor_magnet
Aqara Door and Window Sensor Magnetic Contact Sensor MCCGQ11LM lumi.sensor_magnet.aq2
Aqara Door and Window Sensor T1 Magnetic Contact Sensor MCCGQ12LM ZigBee 3.0
Original Motion Sensor IR Motion Sensor RTCGQ01LM lumi.sensor_motion
Aqara Motion Sensor IR Motion Sensor RTCGQ11LM lumi.sensor_motion.aq2
Aqara Smart Bulb Smart Bulb (E27) ZNLDP12LM
Original Smart Plug Plug-in Outlet Switch ZNCZ02LM lumi.plug
Aqara Smart Plug Plug-in Outlet Switch ZNCZ12LM lumi.ctrl_86plug.aq1
Original Temperature and Humidity Sensor Temp & Humidity Sensor RTCGQ01LM lumi.sensor_ht
Aqara Temperature and Humidity Sensor Temp & Humidity Sensor WSDCGQ11LM lumi.weather
Aqara Wall Outlet In-wall Outlet Switch QBCZ11LM
Aqara Wall Switch - Single (no Neutral) Wall Switch (no neutral) QBKG04LM lumi.ctrl_neutral1
Aqara Wall Switch - Double (no Neutral) Wall Switch (no neutral) QBKG03LM lumi.ctrl_neutral2
Aqara Wall Switch - Single (w/Neutral) Wall Switch w/Neutral QBKG11LM lumi.ctrl_ln1.aq1
Aqara Wall Switch - Double (w/Neutral) Wall Switch w/Neutral QBKG12LM lumi.ctrl_ln2.aq1
Aqara Wall Switch S2 - Double (w/Neutral) Wall Switch w/Neutral QBKG20LM ZigBee 3.0
Aqara Water Leak Sensor Water Contact Sensor SJCGQ11LM lumi.sensor_wleak.aq1
Aqara Water Leak Sensor T1 Water Contact Sensor SJCGQ12LM ZigBee 3.0
Original Smart Wireless Switch Multi-function Button WXKG01LM lumi.sensor_switch
Aqara Wireless Mini Switch Multi-function Button WXKG11LM (2015) lumi.sensor_switch.aq2
Aqara Wireless Mini Switch Multi-function Button WXKG11LM (2018) lumi.remote.b1acn01
Aqara Wireless Mini Switch Multi-function Button WXKG12LM lumi.sensor_switch.aq3
Aqara Wireless Mini Switch T1 Multi-function Button WXKG13LM ZigBee 3.0
Aqara Wireless Remote Switch - Single Multi-function Button WXKG03LM (2016) lumi.sensor_86sw1 or lumi.sensor_86sw1lu
Aqara Wireless Remote Switch - Single Multi-function Button WXKG03LM (2018) lumi.remote.b186acn01
Aqara Wireless Remote Switch - Double Multi-function Button WXKG02LM (2016) lumi.sensor_86sw2 or lumi.sensor_86sw2Un
Aqara Wireless Remote Switch - Double Multi-function Button WXKG02LM (2018) lumi.remote.b286acn01
Aqara Vibration Sensor Accelerometer Sensor DJT11LM lumi.vibration.aq1
MiJia Honeywell Smoke Detector Smoke Detector JTYJ-GD-01LM/BW lumi.sensor_smoke
7 Likes