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

Here is the official LATEST Xiaomi Zigbee Sensor Device Handlers.

These are developed originally from @a4refillpad

The device handlers are located in GitHub here:

or can be brought in via the GitHub integration by using these settings:
Owner: bspranger
Name: Xiaomi
Branch: master

These sensors are very sensitive. Drop offs are usually a result of the Xiaomi sensor trying to repeat through a zigbee router. They do not handle it well. Therefore when pairing you need to make sure all other zigbee routing devices are off and that the device is pairing directly to the hub.

Also interference on the 2.4 frequency band can be an issue. I had to move my wifi channels so they did not interfere with my zigbee. There are many devices on the 2.4 range (baby monitors, cordless phones, bluetooth, wifi, etc). These can all aid in the sensors dropping.

Very Good Notes from @veeceeoh

Besides Aqara Door/Window sensors, I also have some Xiaomi “original” Door/Window Sensors, and one Aqara Leak Sensor, and the information above also applies to to those sensors as well, from my experience.

Some additional information based on my experience and research.

When you hold the reset button down, as soon as the LED flashes, the device has been completely reset and goes into pairing mode. 3 seconds is about right from everything I’ve seen, but really what you should do is hold the reset button in until the LED flashes and then stop pressing the reset button. This should all of course be done after you’ve selected “Add A Thing” in your SmartThings mobile app.

After that initial LED flash, there is a pause, and then you’ll either see the LED flash once (a long flash), or it will blink 3 times (short flashes).

If the LED flashes once, pairing was unsuccessful, and you should short-press the reset button to “wake up” the sensor to try pairing again. The LED will blink as you short-press the button, and after a pause it will either flash once (a long flash) or quickly blink 3 times. If it flashes only once, short-press the button again, and repeat until you see the LED quickly blink 3 times.

When the LED blinks 3 times, the pairing process has started, and you will see a “catchall” message appear in the hub event log in IDE (in My Hubs → List Events, not in the Live Logging window).

Then, if you already have installed a correctly working Device Handler for the Xiaomi device in your IDE, a zbjoin message should appear in the hub event log shortly after the catchall message, and that’s when you’ll see the device show up in your SmartThings app, ready to be renamed.

However, because these are battery-powered “sleepy” ZigBee devices, the pairing process may not complete, so the best advice (based on a post by Ted Tolboom on this Athom home-automation thread) is to continue short-pressing the reset button every 5 seconds, even after you see the LED blink 3 times, until the pairing process is complete (and you see the device appear in your SmartThings mobile app.)

Following the procedures I’ve explained above, I have had 100% success in correctly pairing 4 Aqara Door/Window sensors, 4 “original” Xiaomi Door/Window sensors, and a Aqara leak sensor again and again in numerous tests. With my v2 hub, none of these sensors have dropped their connections.


Why do you want to replace the existing threads? They seem to have a lot of good information in them.

In addition, historically people have generally preferred that each thread refer to only one device type handler, not a group. Otherwise troubleshooting can get pretty confusing.

1 Like

I have been trying to help out with these devices and there are more than 10+ threads active. So people are not using the latest DHs. True other people have also tried to develop their own. I would rather they start with mine (originally a4refillpad) and then further develop the DH. I have had several people provide pull requests to improve these devices.

Your leak sensor has code for the contact sensor

I started from the contact sensor. I was just starting to integrate in to the smart home monitor when I realized there are moisture sensors. So I will need to make some updates. I just got my leak sensor today.

Ok. You probably know way more about coding than I do, but if it helps my handler seems to be working ok, so you can take from it what you want. It probably has pieces of your work anyway.

can you send me a link via IM

I was actually going to recommend you do this. Makes much more sense. Maybe you can also add some information about known problems people see. one I have seen often is the timezone setting.

Yeah - agree time to start a new one.

As a note, I’m having zero luck these last couple of weeks with pairing an aqara motion sensor directly to the hub.

If I turn off all non-Hue zigbee devices (Samsung smart plugs) (and the Hue hub and any close by hue bulbs, though that shouldn’t make a difference) - the sensor just won’t pair (won’t do the triple flash for pairing, bring up thing or device) however close I am to the Hub . And I know the reset/ pairing routine very well .

If I turn on at least one SmartPlug - it will immediately pair to that, with the right fingerprint. (I can tell from the “parent” in the zbjoin message in the hub events listing. )
zbjoin: {“dni”:“EEE0”,“d”:“00158D0001AB31D9”,“capabilities”:“80”,“endpoints”:[{“simple”:“01 0104 0107 01 07 0000 FFFF 0406 0400 0500 0001 0003 02 0000 0019”,“application”:“05”,“manufacturer”:“LUMI”,“model”:“lumi.sensor_motion.aq2”}],“parent”:“58D4”,“joinType”:1}

(58D4 is a Smartthings Plug)

Question - has anyone joined an Aqara motion sensor directly to hub recently? (zbjoin indicating a pairing to 0000)

I’m wondering if it’s something firmware related or such…


You may have hit the 32 device limit

1 Like

I think it’s perfectly fair to start a new thread focused on discussion and support of any of the Xiaomi Device Handlers in Brian’s GitHub repository. There are quite a few people who’ve made modifications to the a4refillpad DHs, but they’re not being actively maintained and updated with improvements.

Yes, there’s a lot of misinformation and early guesswork in some of the various threads on all the different Xiaomi devices, but I think it’s not fair tell people to stop using the threads or close them. These DHs are ST community-created at their origins, and it’s every individual’s choice as to how they get non-official devices working with their hub setup.

Bottom line, if you’re using any of Brian’s updated Xiaomi Device Handlers, then I think it’s great having this thread to avoid confusion over which DH is being used when discussing issues or asking for help.

1 Like

Thanks much @Automated_House!

I didn’t know about this. Bet that’s it - have 23 Trippers, which I think mostly connect directly, 15 Xiaomi devices, etc. etc. Bet that’s it. Thanks!!! (Annoying but I think I know things I can shift around).

1 Like

So the hub has a 32 device limit on the zigbee radio? If so, I am only 1 or 2 away…

1 Like

32 device limit for direct connections to the hub. Devices routing through repeaters don’t count.

1 Like

And per this, found in another thread - if a device is itself a repeater it doesn’t count. (So my Smartplugs, which are repeaters, are connected directly but don’t count.)

Thanks again @Automated_House - you’ve probably saved me hours of Xiaomi heartbreak! I can rearrange some things, I think. But it will put a limit on my buying many more of them. Pity!


@ArstenA OK installed an Original Temp Humidity sensor. I re-paired the device got the catchall and created the device. When I tried to pair using thing method and it came up after applying the DTH as unknown and blank. I then used catchall, but no luck with battery and it went off line once already. it checks in not often enough. I see no temp or humidity or battery. How long does it take to show? If it doesn’t what next?

Update: Temp Humidity now show. No battery.

@ArstenA Still no battery, how long before it shows.? I also don’t see the cability in IDE for the DTH So as of now the Temp/Humidity and the button no battery. Also they both seem to be asleep, as the button doesn’t respond. How do I wake these up? Online for two hours exactly then goes offline and unavailable. What now?

I’ve been reading through the 10+ other threads for a few days now and have been adding devices using the catchall method. (And seeing them drop off after an hour or so). Could the original post be edited to specify the the recommended steps to take to add a device so that drop-offs do not occur? That way everyone can find the steps in a single spot without needing to continue hunting through a bunch of other threads.

Great job Brian on the device handlers.

Why is the motion sensor not registered with the “Illuminance Measurement” capability instead of just publishing the “light” variable in a tile.

Registering the sensor as an “Illuminance Measurement” device would enable sending the sensor data over MQTT Bridge written by @stjohn.