Xiaomi Zigbee Door/Window Sensor, Motion Sensor, & Smart Button Device Type [beta]

[REMINDER] All Xiaomi / Aqara wireless button users

Hub Firmware 25.26 has been released for SmartThings v2 & v3 Hubs

The new firmware includes changes that “break” some functionality in the previous device handlers, but also allows for much improved functionality.

In order to fix the issues and add improved functionality, I have updated all Xiaomi / Aqara Button device handlers (DTHs). All SmartThings v2 & v3 Hub users are encouraged update to the newest DTHs immediately.

Please see this post for all details and links to the updated DTHs.

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

Sorry, I explained wrongly, should be the entire variable energy multiplied by 0.001 not replace the 0.01 for 0.001.
so the correct way should be:

energy = Math.round(energy * 100) * 0.0001
energy = 0.001*Math.round(energy * 100) * 0.01

Ahhh, okay. I have updated the device handler again, with no version change. That line of code now reads:

energy = Math.round(energy * 100) * 0.0001

Please let me know if the updated DTH is working for you, thanks!

I remember I probably already mentioned results in some of my posts lately but here’s again if my message wasn’t clear :slight_smile:

Taking few trådfris out from Hue and pairing them to Smartthings near Xiaomi sensors helped for those double/triple open-close log lines. I was having problems with 3-4 open close sensors. Worst were my front door and back door sensors. Trådfri bulbs are quite near my xiaomi sensors and now I do not have any additional log lines. It’s just either open or close just one time. It also made possible to use xiaomi buttons as doorbells. Without additional trådfri repeaters that wouldn’t work at all.

There is a way to disable the zigbee repeater in tradfri bulb? because when I disconnect power from the bulb using the dumb switch some xiaomi sensors goes offline.

As far as I know, there is no way to disable the repeater function of any ZigBee repeater devices on a SmartThings network.

To avoid any issues when power is cut off from repeating bulbs, I only have Sengled bulbs, which don’t have a repeater function.

So the multiple open/close message problem is solved? I am still working on a way to avoid that in the device handler, but it’s really difficult to test since my door/window sensors don’t have that behavior.

Just note that from what @Tiago_Goncalves said above, if the power is cut off to Trådfri bulbs, then any Xiaomi / Aqara devices connecting through them will go offline.

Yes, it is solved. I guess only way to test it would be taking one sensor far away enough from hub and see if that makes it.

Usually cut off for example in my home means that hub and repeaters are all off. So it doesn’t really matter if sensor is connected to hub or repeater. They all should be back online when cut off is over. Well… if cut off takes many hours then it might be issue for xiaomi sensors.

For some reason in few hour cut offs I have noticed that some of Ikea trådfri bulbs seems to be “unavailable” according ST app. When pressing “turn on” in application bulb turns on and “unavailable” status disappears. At the same time xiaomi sensors have not reported any activity or battery status to st hub but It usually start after Ikea bulb “unavailable” disappears and status in normal. It feels like xiaomi are trying to send information to ikea repeater but ikea has some problems and have to be refreshed. Have anyone else noticed this?
In short cut offs they all seems to usually come back online without problems. Especially now when I removed those residual-current relays from my system.

As veeceeoh noted, I don’t think it’s possible to disable the “repeating”/routing functionality of a bulb. That is likely something that would have to be done in firmware. I see you mentioned Xiaomi devices were the (only?) ones you were having problems with. In my experience, Xiaomi devices are reluctant to change routes–if I pair mine through the hub, they try to stay paired to the hub (probably why most people recommended pairing them this way initially). If I pair them through a specific repeater (something you can’t force but can encourage–and verify with XCTU), they tend to stay routing through that one. Some people have noticed that they do change routes, but I’ve never noticed any of my Xiaomi devices do that (may depend on chance, your Xiaomi devices, or your routers). This is in contrast to regular ZHA devices, which will change routes if they can’t find their router (or the hub/coordinator).

So, if my observations are also correct for your network, one way you can avoid this problem is not pairing Xiaomi devices through Trådfri bulbs that you think you’re going to turn off. Hopefully you have other repeaters that work well in this case (or slots left on the hub). The other solution, of course, is just to not turn them off. :slight_smile:

I was counting of the “reluctance” to change routes because I normally pair it near the hub and let it there for some hours. in Zigbee I only have tradfri and xiaomi.
This weekend I had the brilliant idea to switch off my 3 tradfri bulbs and half of my sensor went down. some of them reconnect in the next interaction others I had to do the manual catchall method to reconnect (older versions mainly).

Just as an update, bought an ikea tradfri outlet that stays always on and until now (2weeks) no more dropped sensors.
AS a curiosity, I bought to the button that comes with the outlet, but doesn’t have a DH.

So I have it as a thing, but when I press the on/off button the smartthings assumes that is xiaomi outlet (maybe due to parseReportAttributeMessage) and turn on or off my xiaomi outlet accordly without any configuration done.

The Trådfri control button only works with the outlet. It can’t be used as an independent button to control other devices. This is explained in the “Try to create Device Handler…” thread you linked to.

As long as power is supplied to the Trådfri Outlet, it will provide the ZigBee Repeater function. You can still use it to switch on/off something that is plugged into it.

I have several Xiaomi sensors working w/o any issues… I have noticed that there are two DTH for the door/window sensors in bspranger github thread. One appears to have a battery tweek.

Question… Do I need to use both DTH on the Xiaomi Door/Window sensors?

Thanks guys for great work…

You can only use one DTH for any device.

The bspranger repository has a DTH for the Xiaomi Door/Window sensor and a DTH for the Aqara Door/Window sensor.

If you’re using Xiaomi Door/Window sensors, you want the DTH located here.

The battery “tweak” was just a change to the text of the log output, nothing about the way the battery percentage is calculated, etc.

I’m having an issue with one of my two Xiaomi Zigbee sockets. 1st one, perfetly work and locted around 12m from the hub. 2nd one is after the 1st one around 5m . 2nd one perfectly work when it is next to hub, but not communicating when it is in its place. I suspect the 2nd one is routed directly to the hub which is too far. Is there a way to change to routing of Zigbee network ? Can I force my 2nd socket to route its data via my 1st socket ? suggestions ? Hub V2.

1 Like

There is no way to control the ZigBee routing of the majority of consumer ZigBee smart home devices, including Xiaomi / Aqara devices. A ZigBee mesh network allows devices to decide their routing based on signal strength, number of hops, etc. The routing can even change after a device has been paired, multiple times, especially if it has been moved after being paired.

However, from my own experience and reports from users, Xiaomi / Aqara devices are stubborn to change their routing, so you could try re-pairing your 2nd Xiaomi socket even further than 12m from your hub, but near the 1st socket, with the hopes that the 2nd socket will route via the 1st instead of directly to the hub. Then quickly unplug the 2nd socket, and re-plug it into the location where you want to use it.

The only problem with this and any other solution to try to “trick” devices into a certain routing path is that there are no tools to discover the routing besides using an XBee ZigBee module.This thread focuses the use of XBee modules as routers to improve a mesh network, but there’s also discussion about their use in displaying a map of all devices on a ZigBee network.

I’ve managed to pair the Xiaomi button on my ST Hub, but I don’t know which firware my device has, so I picked the Handler for the latest version (bspranger repo), and it seems to be working just fine. But I have a problem, the button won’t trigger individual devices (I have 3 meross smart plugs) it only triggers the Scenes I have configured on ST App. Is this suppose to be like this or did I chose the wrong firmware version?
P.S. I have Smartthings Hub V3 and the new app.
Any help please? Thanks.

1 Like

@fpintodias How did you manage to connect the button the ST Hub V3? I have the exact same, but can’t make the connection between the two. I’ve loaded bspranger repo device handler and created new device…but stuck now as to how to connect. Please provide steps or a link to a post that does. Much appreciated!!

Connecting Xiaomi devices can be a swine.

  1. Put hub in pairing mode. In the app go to devices, +, Scan Nearby
  2. While as close too the hub as you can get, press the little pairing button on the new Xiaomi device and keep pressing it every 2 seconds. As some point you will see the led flash pattern changes. (e.g. from a single slow pulse to multiple fast pulses). Keep going with the presses every 2 seconds and you should see a new device appear in the app. Save this and then you can stop pressing the pairing button. Warning, this can take over a minute.
  3. Go into the IDE and look at the new device. it should have both a Zigbee ID and a Device Network ID registered against it. Also look at hub events and you should see a Zigbee join event for the time you added the device and the Device Network ID will be the same as the new device shown in the IDE.
  4. Leave the new Xiaomi device near the hub (almost on top of it if you can) for a few hours until the new device shows a battery reading on the app.

Sometimes the battery reading never comes and the sensor drops off. In which was you need to repeat steps 2 and 3. Yes it can be a swine.

Hope this helps.

I left mine on top of the hub. Seems to do the trick. Originally, I was in another room and holding it next to my phone when I realized it was near the wrong device. :joy::joy::joy:

BTW, the checkInterval is set to about two hours. My battery level did eventually appear though. Who knows if its correct.

The checkInterval of around two hours is about right for Aqara devices because the battery report appears at intervals of a little under an hour. However it takes a bit longer than two hours to start reporting so it is a good idea to ensure the device is activated a few times in the first hour or so.