SmartThings Community

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

Update 02-11-2017: Here is an alternate thread discussing Xiaomi Zigbee devices. It has handlers and information that is more up to date than what I have posted:

I have created a simple device type for the Xiaomi Smart Button that can be found various places for around $10. Other users have stated that this device loses connectivity to the hub after a while, but I have only had the device in hand for a couple hours so I’ll report back what I find.

The device should work with SmartApps that work with button devices like the Aeon minimote. It registers as button 1 pressed, and button 1 held if you hold it down for 4 seconds (configurable in preferences, but a lower number may affect reliability of the device properly distinguishing the two).

Edit: Seems like what @Kriskit reported is true. Two of my devices are not communicating with the hub after a few hours. I will try to figure out what is going on, but without documentation it might be a lost cause.
As of the SmartThings Hub v2 Update on 2/29, this no longer seems to be the case. See post 25.

Also works with my SmartApp to adjust lights in a very customizable manner:
Edit: with my SmartApp button 1 is for pressed and button 5 is for held. I know it doesn’t make sense, but the app was designed for the Aeon Minimote and the Enerwave Scene controller. I’ll consider changing it in the future.

Edit 3/5/2016: Here is a simple device handler for the motion sensor:

8 Likes

Here is a simple device type for the door/window sensor:

https://github.com/erocm123/SmartThings/blob/master/xiaomi_door_window_sensor/xiaomi_door_window_sensor.groovy

4 Likes

If the door/window sensors work you’re going to save a lot of people money!

1 Like

Well, before anyone gets their hopes up, I need to figure out why these devices disconnect a few hours after pairing. I’m a Z-wave guy who is starting to get into Zigbee devices so I still have a lot of reading to do. Are there any Zigbee experts out there that could shed some light on why these devices disconnect?

When should the devices disconnect? After how many hours?

Thanks a lot

These devices aren’t certified for the zigbee home automation protocol (which is what SmartThings uses).

So what they do and why they do it is totally up to their manufacturer, and is designed to work with their proprietary controller.

As discussed in the “probably won’t work” thread, some of the community zigbee experts have already tried these devices and reported that communication could not be maintained.

If you can get further, that’s great.

Thanks @JDRoberts, I am doing some testing on these devices, but at this point I am not very hopeful. They seem to disconnect after about an hour of inactivity. I have a lot of experience with Z-Wave, but not nearly as much with Zigbee. With the lack of documentation on these devices, I’m not sure how far I can go. It would be fantastic if these devices could work with SmartThings because of their price and quality. They really do seem well built, small, and look great.

The disconnect seems related to this:

https://www.digi.com/wiki/developer/index.php/XBee_Sleeping_Problems

Again, I am not very familiar with Zigbee, but it almost seems like the Controller is requiring the device to rejoin the Zigbee network after a certain amount of inactivity.

2 Likes

In my case it has remained connected for more than two hours. However, it was not inactive because i had been playing with it.

I am now going to leave it alone and check back in two hours and see what happened.

1 Like

I can confirm it gets disconnected. I left it alone for 4 - 5 hours and now the device does not communicate.

Who know how to pair Xiaomi Button with hub, click the link hole ? or double-click the link hole ? or click and hold the link hole? I can’t found the button with hub

Click and hold will reset the sensor. A single click will join the sensor to the SmartThings Zigbee network. Sometimes it will take a few tries, and you might have to reset it first before trying. As mentioned, the sensors will not stay connected after inactivity. My theory is that the devices do not finish the pairing process because of differences between SmartThings and the Xiaomi hub. Because the sensor does not finish the pairing process it does not write it’s network configuration to NAND flash. So, when the sensor goes into a “sleep” state (after a certain amount of inactivity), it forgets its network configuration.

Something of interest is that if I join the sensor to SmartThings, reset the sensor, and join it again without removing it from SmartThings, the sensor seems to be sending normal Zigbee join information:

90a33378-6196-4a24-8821-f54116119fe5 9:34:57 AM: debug [raw:0104 0000 01 01 0100 00 DB91 00 04 1234 0A 01 02FF4C0600100121EF0B21A8012400000000002171022054, profileId:0104, clusterId:0000, clusterInt:0, sourceEndpoint:01, destinationEndpoint:01, options:0100, messageType:00, dni:DB91, isClusterSpecific:false, isManufacturerSpecific:true, manufacturerId:1234, command:0A, direction:01, data:[02, FF, 4C, 06, 00, 10, 01, 21, EF, 0B, 21, A8, 01, 24, 00, 00, 00, 00, 00, 21, 71, 02, 20, 54]]
90a33378-6196-4a24-8821-f54116119fe5 9:34:57 AM: debug Parsing ‘catchall: 0104 0000 01 01 0100 00 DB91 00 04 1234 0A 01 02FF4C0600100121EF0B21A8012400000000002171022054’

2 Likes

Finally does this device work or it gets disconnected after a few hours?

So, with the latest Hub v2 update (02/29), it seems that the sensors no longer get disconnected after a period of time. Something must have changed with the SmartThings Zigbee pairing process to coax the devices to write the network settings into NAND memory (my theory). I have been playing with the Door / Window sensor, Smart Button, and Motion Sensor. If you have the device and want to test, please post back if you are experiencing the same.

Although the devices should stay attached to the network now, they are far from perfect. Some of these things can most likely be resolved:

  • Pairing still incomplete. The devices do not initially report their fingerprinting cluster information so the devices look incomplete in the IDE. This also makes it impossible to automatically assign a device handler.
  • Battery levels. I don’t see the devices reporting battery levels, but this may be a configuration issue.
  • Motion sensor only sends “active” status. This could be resolved using runIn() in the device handler, but SmartThings scheduler woes may affect this.
5 Likes

This is very interesting!

Are you saying we can pair the Xiaomi sensors and then assign a custom device type and they will work?

If so, it is great news. The price is absolutely great and the design as well.

@ktsi Yes, with the limitations mentioned above. I have had the door sensor, motion sensor, and button connected for a few days now and all are still working. I would encourage you to try a couple sensors out for a few weeks and see if they work for you before outfitting your entire home.

The main problem with the devices right now is that they don’t report battery life so you will have to keep an eye on them.

I placed an order for two door and one motion sensor.
It will take some time for them to arrive from China.

Unfortunately i gave away my smart home kit some months ago.

If you can find a way to report the battery it will be absolutely fantastic.
BTW, what about the motion sensor? If ti only reports action can it be used in rules?

Yeah, it will just take a little programming to simulate an “inactive” event. Not as good as having the device report it, but it should work as long as the SmartThings runIn method is working properly.

Eric are we to expect a new device handler for the Xiaomi sensors? Are you going to put any more work in it?

I am by no means demanding anything, just wanna know.

I plan on making a device type for the motion sensor. The two device types above for the Door Sensor and Button should actually work well. I won’t dedicate too much time to figure out if these devices can deliver battery reports, but I’ll look into it when I get a chance.

Thanks a lot Eric. Eagerly waiting for your motion sensor device type and possible progress regarding battery status.
:slightly_smiling: