Xiaomi / Aqara ZigBee device drivers (possibly may no longer be maintained)

It looks like the activityLevel attribute is declared in the code as a string rather than a numeric type, so arithmetic operators are not available. That being said, from what I can see in the code, the sensor does indeed report numeric types for this (and the driver even converts them to an Integer when parsing). Until the actual maintainer of the driver has a chance to look at this, my suggestion in the meantime would be to edit the line in the driver that looks like this (on line 43 in the current version but may vary on others):

attribute "activityLevel", "String"

to look like this:

attribute "activityLevel", "Number"

This is assuming there isn't some other reason this is declared as a string. I don't have one of these devices and can't test for sure, but it looks like the assumption elsewhere is that this will always be an integer value from the device.

I don't know nearly as much about these as Keith does, but since you haven't received a reply yet, here's my take on this:

  • I think I've seen that error a time or two, especially if I just paired the device. Xiaomi device drivers parse the data received back manually instead of relying on built-in Hubitat methods due to the fact that they will occasionally send data that the Hubitat methods can't handle. Without debug logging enabled and the corresponding output (probably right before this, but again, debug logging needs to be on) from what it was trying to parse, I don't think it would be possible to say what this might have been, but the device was likely sending something that never came up in regular use and so wasn't being handled right. It could have also been sending garbage data for some reason (dying battery?).
  • The "falling off" is likely to be a different issue. A driver can't cause a device to fall off, though if it's not parsing the data correctly, an event may not get generated. If you haven't seen this thread (mostly just the first post), it's pretty much required reading for using these outside Xiaomi's own system, e.g., on Hubitat: Xiaomi & Aqara Devices - Pairing & Keeping them connected
  • I'm not sure what three flashes of the LED means, but my guess is either that the device can't find the parent or hub (only suggesting that because it's consistent with what you noticed) or maybe low battery. If you haven't checked the voltage (I'd do it manually instead of trusting the driver) or just replacing it to see if it helps, that would be worth doing and then re-pairing. But again, a re-pair won't help if it's not either consistently within range of the hub (probably risky) or routing through "compatible" repeaters (and having any that aren't is also risky) per the thread above.

The battery is a brand new panasonic.
TBH I'm not that fussed as I have all my Xiaomi/Aqara devices connected to my hub using Mi-Connector.
I just left this one to see how it was performing.
I kept moving it around my house to see how it behaves but it just keeps dropping off the zigbee network.
As I have 2 hubs I have now re-enabled the zigbee radio on the 2nd hub and paired it to it. It has been rock solid on the 2nd hub in the same physical position that it keeps failing on hub 1.
Hub 1 is using zigbee ch 20 and hub 2 is using ch 22. My router is using fixed ch 1.
Ironically hub 1 has 3 devices that repeat (2 x Salus outlets and 1 x Aone dimmer) and hub 2 has none. Could it be the repeaters causing the issues? I'm not convinced as my zigbee network was rock solid until about 3 months ago and then started playing silly beggars hence my move to using Mi-Connector.
I only posted the info in case anything could be gleaned from the error code.

Thanks for the comprehensive response though. :+1:

Had just a few Xiaomi motion sensor devices drop off at the outer limits of my house (monitored using Device Watchdog, an excellent app). Decided to get 2 IKEA Tradfri zigbee repeaters. Very nice little devices and a reasonable price too. Hooked them up and noticed several Xiaomi motion devices then disconnected from HE (not just those nearby, interestingly). Just left everything alone for almost 24 hrs expecting all devices to find their new route. Didn't happen. So I've just reconnected them with a short press to their reset buttons while in discovery mode. They all reconnected nicely. Now to see if they stay connected better than before!

1 Like

Changet the string to number and now it works fantastic!!!! :slight_smile:


1 Like

A version with MQTT publishing built in

Useful if you are using MQTT and Node-red in conjunction with HE


@veeceeoh any plans on adding support for Hubitat Package Manager?


Sadly not. In fact worse.
What a strange world.

@veeceeoh in case you want to add the two types of Aqara curtains to your list I have now released a feature complete driver:

Just a question here if I may...

"Once you put in monitoring" - is this an XBee thing or can the Xiaomi devices be configured to check-in periodically? I have a few Xiaomi devices that have been dropping off lately, even the 'last activity', on the device page, does not always seem to be reported correctly, but the device still works ok.


Hi, If this is not the correct place to ask this question please let me know.

I have setup a Aqara Vibration Sensor (DJT11LM) in my test environment and had a lot of success pairing and setup. I can see the sensor changing state from inactive to active and I believe I have set the "Closed Position" to Active and the "Open Position" to inactive. The issue I am having is that the contact state moves to Closed when the Active state is achieved but never returns to Open when the Inactive state is achieved. I want to use it as a vibration sensor on a clothes dryer to control a fan in the laundry room. Is this a limitation of the device or the driver. I am using the latest BETA release.

Have this device, (Honeywell zigbee Fire Alarm Detector.)
Start zigbee pairing in hub,

Pressing on the button in the front (The one with the red led)
And it is just changing the sound volume
Pressing 3 times, 4 times, long press, ...
Nothing happened. it is not discovering.
Have I done something wrong?

@veeceeoh hasn't been on this forum since the end of February.

@WetCoaster What is referred to here is one of the ways you can monitor devices using either an App or RM.

@craig.allen.20 I might have time to look at that driver in a week or two, but as it is I don't think there is anyone on this forum who can answer you without checking the code. Patience :wink:

@9999341 I have one of those device but haven't even begun to look at it. I'll try to pair it soon and see what is up. One thing I can say is that these devices can be VERY sensitive to how good the mesh is. Especially during pairing. Try pairing it in close vicinity to the hub, if that resolves the issue it is a mesh problem. Ask about that in one of the proper threads :slight_smile: You can @ mention me there and we can take it from there.

1 Like

I should be receiving these 3 items tomorrow as I wanted to check if they would be "reliable" and stay connected to the HE. What I wanted to find out was what drivers I should be using for these

Mi Wireless Switch :YTC4040GL
Mi Window and Door Sensor: YTC4039GL
Mi Motion Sensor :YTC4041GL

Thank you

These model numbers don't make sense, must be a sales model number used by someone, I think after checking the model numbers on the actual devices you will see which drivers will fit. YTC4040GL is most likely WXKGL01LM for example. The contact sensor is probably MCCGQ01LM and the motion sensor RTCGQ01LM.


Hi markus

Okay thanks, I should have them tomorrow and I will have a look for the model numbers.

Hi @markus you were correct the model numbers you gave me are the correct ones.. I have the Xiaomi smart button setup and wanted to ask how I setup RM, I basically want to know how the button pushes are labeled, So I have setup a motion lighting rule for the kitchen, what I want to do is press the button once to disable the lights from turning off even if motion is not detected. When I chose button as the option to disable turning off, the next option is;
Kitchen Button buttons to disable off? If I wanted to use 1 click to turn off would I put 1 and if I wanted a double click to turn this on would you put 2 , then a hold would you put 3.

Sorry I hope this makes sense.

I don't really know how this driver implements it, I use my own driver for this button. With that said, looking at the driver code, button clicks 1 to 5 would be button 1 to 5, so double click is 2. Held is a separate event and is 1 for event held.

Is your driver available and if so can I ask you for a link please. How does yours work with regards to the button presses?

It is not, I've not released it, I might if these drivers remain unsupported much longer, but I don't want to disrespect the hard work done be @veeceeoh. In mine, button press 6 would be held in addition to the held being 1. It does all kinds of other things differently as well, it is written from scratch and has nothing copied from this driver.

Try the veeceeoh one, they're good drivers.

@Markus will do, I just need to know how to do the held option.


Download the Hubitat app