[OBSOLETE] Xiaomi Sensors and Button (beta)

You said you’re trying to connect the round temp / humidity sensors to your hub right? Those are the Xiaomi (“original”) Temp / Humidity sensors.

You also said that you’re using the device handler by A4refillpad for them. So, you got the device handler code from here, correct?

I am double-checking on this because that message you copied:

LRS unknown is read attr - raw: 8AA5010000240500420E6C756D692E73656E736F725F6874, dni: 8AA5, endpoint: 01, cluster: 0000, size…

is not a message that the A4refillpad device handler would generate in the Live Logging window of the IDE.

So where are you seeing that message?

Also, are you using a SmartThings v2 hub, or another type of ST hub?

I am using a ST Hub US V2

I am using the original round temp sensors yes.

It says they were ONLINE but show nothing in the app for any of them after hours of waiting…

as for the info at this point I have no idea where I found that… I’m so confused and frustrated at the moment.

SO apparently I’m doing something wrong here…
I push the sensor on the button the light flashes it actually flashes 4 times then delay one more time…
I go to the App on my phone and search for device.
I push the button the sensor again and it shows up in the Hub event list as a catchall
I then go in the IDE and create the device using the 4 digit/letter code 7th group from the left
I then go back into the app on my phone and go back, then I see it there…
I have left it like that and it shows none of the reading and I have also hit add device again and it finds the device and I say OK.
I hit the device and it still shows nothing…

so apparently I am doing something very wrong here…

I have the same issue .

Sensor 02 unknown is read attr - raw: DFE90104031C000029E203140028FF100029D926, dni: DFE9, endpoint: 01, cluster: 0403, size: 1C, attrId: 0000, encoding: 29, value: 26d9290010ff28001403e2

All was working well until I reset hub

I used a4refillpad/Xiaomi code

@cowboysdude & @busybeee:

Well, we’re all doing something wrong here, because these sensors were never meant to be used with a SmartThings hub! :rofl:

Anyhow, yes these sensors do require some patience, and there is definitely a sequence of how things should be done in order to get them paired. People seem to have all kinds of opinions based of the hoops they’ve jumped through that luckily got their sensors working for them.

Me, I like working with facts, and the best facts are to look at what the manufacturer Xiaomi gives as instructions on how to pair their sensors with their own hub. That’s because what the sensors do when you press the long-press or short-press the reset button does not change.

So I did a bunch of searching and research, and the best explanation of the the functions of the reset button and the meaning of the LED flashes was from a manual for the Aqara Door/Window sensor. I have posted about this manual and the best method for pairing Xiaomi sensors in this post.

I have some Aqara Door/Window sensors, and also some of the “original” Xiaomi Door/Window sensors, and one Aqara Leak Sensor. And I have paired all of them to my v2 hub using the normal “Add a Thing” method in the SmartThings mobile app, and I believe you should be able to do that too. Failing that, you can use the “catchall” method, but the order of steps that you gave is not quite correct.

It’s in my post that I linked to above, but I’ll repeat the steps again here:

  1. Install the device handler in SmartThings IDE, and I highly suggest using the one from @ArstenA in the bspranger Xiaomi Device Handlers for SmarthThings GitHub repository. The direct link to @ArstenA’s device handler for the Xiaomi (“original”) Temp/Humidity Sensor is here. Copy & paste that code completely replacing the code you have from a4refill, save, and make sure to click Publish -> For Me.

  2. In the IDE, click on My Hubs, which should take you to a page showing information about your hub, scroll down to “Events” and click the “List Events” link. That takes you to the hub event log page, which is the only log where you will see the “catchall” message followed by a “zbjoin” message when Xiaomi devices have paired correctly.

  3. In the SmartThings mobile App, go to the Things list, and press “Add a Thing”.

  4. On one of your Temp/Humidity sensors push and hold the reset button until you see the LED blink (Xiaomi says hold the reset button for 3 seconds), and then release the button. After a short bit of time, the LED will flash AGAIN - either once (a long flash), or 3 times (3 rapid flashes).

  5. If the LED flashed 3 times, then the Xiaomi sensor is telling you it has linked to the SmartThings Hub, but the pairing process still needs to be completed. Refreshing the Hub Events Log page would reveal a “catchall” message from the device. I have done loads of testing and confirmed the catchall message happens the first time you see the LED blink 3 times.
    If the LED flashes only once, the Xiaomi sensor has not linked to the SmartThings Hub yet.
    In BOTH situations, you will need to short-press the reset button a number of times, until the Xiaomi sensor shows up in your SmartThings mobile app ready to be renamed.

  6. Regardless of whether you saw the LED flash once or 3 times in step 4, you should SHORT-press the reset button. The LED will blink when you push it, then wait a bit of time, and then flash again - either ONCE, meaning the device still hasn’t linked to your hub, or 3 times, meaning the device is confirming that it has joined the hub. On my Xiaomi “original” Door/Window sensors, those 3 flashes when I short-press the reset button sometimes look like 2 flashes, then 1 flash. Your sensor may do the same. Don’t worry. The important thing is that if the sensor is still not linked to the hub, it will be one long flash.

  7. If you have seen the LED do 3 flashes, then repeat step 6 (short-press reset, wait for 1 or 3 flashes, then short-press again, etc) until you see the device appear in your SmartThings mobile app, ready to be renamed. If you refresh the Hub Events Log page, you will see a “zbjoin” message in addition to the “catchall” message. The “zbjoin” message tells you that the device has correctly paired with your hub, and when you look at the details for that Xiaomi device in IDE, it will display the device’s Zigbee Id.
    However, if you have not yet seen the LED do 3 flashes, repeat step 6 until you DO see 3 flashes, and then continue repeating step 6 until the device appears in your SmartThings mobile app ready to be renamed. In either case, I would give up after about 2 minutes of repeating step 6, cancel “Add a Thing” in your mobile app, and try going back to step 3.

  8. If you have tried two or three times, and haven’t seen the device show up in your SmartThings mobile app, then by all means, use the “catchall” method. But even after the LED flashes 3 times, I still recommend short-pressing the reset button again and again (Step 6) for AT LEAST one minute. Then look for your sensor’s Network ID in the “catchall” message and manually add it as a device in the IDE. The reason for doing the short-presses is because the sensor needs to be kept “awake” to complete the pairing process with your ST hub.

A couple of extra notes:

• After the sensor is paired, if you short-press the reset button on an “original” Xiaomi sensor (like yours), it doesn’t actually do anything. The message is intended only as an announcement message for the Xiaomi hub, but on the SmartThings hub, it sees it as a “read attr - raw:” and doesn’t know what to do with that. On the Aqara devices, however, the announcement message also includes the battery voltage, so most of @ArstenA’s device handlers are set up to read that voltage and immediately update your reported battery percentage.

• The battery percentage will NOT display for you newly paired Xiaomi sensor for 60 minutes if it’s an “Original” Xiaomi devices, or 50 minutes if it’s an Aqara device. This is just because the ST hub doesn’t catch that information until the devices first check-in. The other status attributes (open/close, dry/wet, temp/humidity, motion detected, etc.) should start working immediately, though some people have reported it can take a bit of time for environmental type status reports to start coming in. If you are using one of @ArstenA’s device handlers and don’t see the battery percentage displayed within 60 minutes of pairing, then that’s a sign that something didn’t work right during pairing. It’s unlikely for that to happen if the “Add a thing” method was successful, but I would not be so surprised by it if you had to use the “catchall” method to pair.

• Generally speaking, if the pairing process didn’t complete successfully (again more likely if you had to use the “catchall” method), then a Xiaomi Sensor won’t stay connected much longer than 2 hours. If you’ve made it past the 2 hour mark and it’s still connected and checking in, then it will likely (but not 100% guaranteed) continue to stay connected.

1 Like

This is a brilliant and concise post for pairing these devices.
I do not want to steal your thunder as you have done all the hard work.
Would it be possible to create a new thread titled something like “How to pair Xiaomi Devices”. A Guide. DO NOT POST ON THIS THREAD." Or something similar.
People keep asking the same question over and over again and if they could either find it or be pointed to it would be great.
As I said I think it would be a good idea and I do not want to take any credit for your sterling work.
Just a thought and thanks.

Thanks, @bobbles.

Actually, @ArstenA has copied pretty much my same explanation as this into the first post of his ST Community thread focused on using Xiaomi devices with the more updated Xiaomi device handler repository that he’s maintaining on GitHub.

However, if he prefers this text explanation over my previous one, he’s welcome to paste that in instead!

I’d just like to hear some feedback as to whether this helps other people, because I went through many many pairing attempts with the Xiaomi sensors I have in order to come up with this set of steps.

In any event, I have ordered 3 other Xiaomi devices - including one that I haven’t seen anyone using with SmartThings yet - and have 100% confidence that I’ll be able to get them paired and working with my ST hub. Time will tell, though!

I really do appreciate such a detailed how to!

Unfortunately it’s not working [app never finds it]…
I did the catchall and it’s not working either [Shows nothing in the app]…

It cannot find the device pairing it normally and if I add it won’t show any info even though in the hub events it shows all kinds of temps and humidity readings…just not on the app.

I have never seen anything that would suggest that it’s

Thank you @veeceeoh for the information.

I am still in the same boat as @cowboysdude.

However when i changed the Type to : Temperature Sensor from @bspranger - xiaomi-aqara-temperature-humidity-sensor code and guess what it shows temperature and humidity on the app .

So i am not sure why it doesn’t show up in the app when i use xiaomi-aqara-temperature-humidity-sensor code by @bspranger

Thank you…tried that and I still cannot get anything to work or show… :frowning: I’m afraid these 4 sensors are about to meet my 4x4 and a hammer… a week of this is insane. I’m literally sitting 10’ from the hub and my router in another room completely… so I have NO idea why this isn’t working.

If your Temp/Humidity sensor is the circular-shaped one, then the @bspranger - xiaomi-aqara-temperature-humidity-sensor code found here is the not the correct device handler. It’s for the Aqara Temp/Humidity sensor, which is shaped like a square with rounded corners.

So it sounds like the @bspranger Aqara device handler is working - is it?

Okay, I can’t explain why you’re not able to get a proper pairing with the “Add a Thing” method, but it sounds like something is missing when you’re doing the “catchall” method.

If you are seeing temp / humidity reports in the hub events, that means it’s paired, but not added as a device correctly.

Can you post a screenshot for what you see for one of the sensors in your SmartThings mobile app?

I have the Aqara Temperature Humidity Sensor which is square .

No . @ArstenA device handler (https://github.com/bspranger/) does not work .

It used to work with https://github.com/a4refillpad/Xiaomi before HUB reset

So should i revert back to @a4refillpad device handler ???

I am confused. You said:

However when i changed the Type to : Temperature Sensor from @bspranger - xiaomi-aqara-temperature-humidity-sensor code and guess what it shows temperature and humidity on the app .

So does the xiaomi-aqara-temperature-humidity-sensor device handler from @bspranger work for you or not?

By the way, none of the @a4refillpad device handlers were intended to use with Aqara devices. The Aqara sensors are quite different from the older “original” Xiaomi sensors.

This is what I see:

I hit the refresh button and it shows up in the IDE under that device:
COMMAND refresh refresh command was sent to LRS Changed: true

I looked under Living Logging and it says this when I hit refresh:
a609361-8837-4190-b812-22cbc8193184 8:08:59 PM: error java.lang.IllegalArgumentException: Needs to be string or int, received null value: null
ea609361-8837-4190-b812-22cbc8193184 8:08:59 PM: debug LRS: Configured health checkInterval when refresh()
ea609361-8837-4190-b812-22cbc8193184 8:08:59 PM: debug LRS: refreshing

BUT still nothing showing in the app… apparently the hub sees it then it just goes dead…so the catchall is cool and all but I don’t want to have to keep figuring this out when the hub says 2 hours later:

OFFLINE for that device…

I’m VERY computer literate but I cannot believe it should be this hard…so I have to be doing something wrong.

I changed to the DH you suggested and put that in as my DH…I have to add the device through the IDE on the internet because my phone app doesn’t see it…once I enter it in the device IDE the phone sees it but reports nothing…so I’m confused.

So hopefully someone can tell me what I’m doing wrong here… but 4 hours of this for tonight is enough for me :slight_smile: I’ll check back in tomorrow. HUGE Thanks and sorry for being such a pain…

I apoligize for the confusion . “from” - I meant i changed it from @bspranger device handler to the one in ST IDE

I had @bspranger - xiaomi-aqara-temperature-humidity-sensor device handler ,even though i was able to see the reading in the events the ST APP showed up blank like @cowboysdude screenshot.so it does not work

I then changed the Device Type to : Temperature Sensor in the DROP DOWN instead of the xiaomi-aqara-temperature-humidity-sensor device handler.


It worked for me for the last 3 months where it gave me Temp ,Humidity ,Pressure and even Battery readings.

Ah, okay, I get it. Well @ArstenA and some other contributors have been working a lot in the last week to improve the device handler code. Some change made in the past few days to both of the Temp/Humidity sensor (“Original” & Aqara) device handler code must have made the updates to the device display in the SmartThings mobile app. I will add this issue on GitHub, and hopefully it’s fixed in the next day.

Yes, it may seem that it’s been working. I don’t have a Temp/Humidity sensor yet, and haven’t closely compared the way the “original” versus the Aqara sensors report Temp/Humidity, but it may not be the same. If it’s not the same, then using an incorrect device handler will result in erroneous values reported.

I can say the a4refillpad device handlers definitely do not report the battery voltage / percentage correctly. The method for that was figured out after a4refillpad stopped updating his collection of device handlers, and having done a LOT of research and reading about these sensors, I know the method used to read the battery voltage data in @ArstenA’s device handlers is 100% correct.

All of that said, it’s everybody’s personal choice as to what they do, so use whatever device handler you think works for you. All I know is that as soon as I get my Aqara Temp/Humidity sensor I will make sure that the device handler in @ArstenA’s repository is working 100% as best as it can work with the SmartThings hub.

Sorry - I have a question that could help with troubleshooting here, if you’ve got time:

In which “events” are you seeing the temp / humidity changes listed?

Is it in IDE: Live Logging or Hub Events, or is it in the “Recently” tab when viewing your sensor in the SmartThings mobile app?

A screenshot showing some of these events would be incredibly helpful, again if you’ve got time.

First I would like to thank @ArstenA and all the contributors for the device handler.

Yes I agree however the only reason i was referring to a4refilpad becuz everything was working until I reset the hub and then my location list got thrashed and i was getting error s and then had to talk to ST support to reset and clear location and start fresh .

Thanks for you input ,I will be using @ArstenA device handler only.I will post the screenshot you requested in a while .

That sounds like a frustrating experience, sorry to hear that. I was using a SmartThings Link for NVIDIA Shield as my hub to begin with, and after hours and hours of trying to get Xiaomi sensors to work with it and failing every time, I realized the problems were probably because the Link doesn’t work the same as the full v2 standalone hub. So I got a v2 hub, and had to uninstall / remove everything from my Link hub and then set it all up again from scratch on the new v2 hub. It was no fun at all, but all the Xiaomi sensors paired correctly right from my first try.

I’ll try my best to see how I can help!

I don’t understand what is wrong with the DH for the aqara temp/humidity sensor. I am using android and it looks like this