Xiaomi & Aqara Devices - Pairing & Keeping them connected

From everything I have read, yes, that creates potential for issues due to interference, especially if the two hubs are located nearby. Also, if you're now using channels 20 & 21 for Zigbee, your 2.4GHz WiFi should be set to channel 1 for the least interference. See my earlier post in this thread here (if you haven't read it yet.)

As for Aqara sensors vs original Xiaomi ones, I have a bunch of each of Door/Window Sensors and Temp/Humidity sensors, and haven't seen any trend for one type or the other dropping their connections.

My SmartThings hub, which is in the same centrally located room as my Hubitat and my 5GHz/2.4GHz WiFi router, is on channel 15, and I also never had any Xiaomi devices (original or Aqara) drop off.

Here's what I've tried for channels with my Hubitat Hub so far:

  • Channel 26 - Most Xiaomi devices paired relatively easily, and out of 21, just a nearby Aqara Leak Sensor and a more distant original Xiaomi button lost their connection after 3-4 weeks. I did some reading on Zigbee & 2.4GHz WiFi interference, and after l checked the WiFi channels used by neighbors and read up on how my WiFi router handles its 2.4GHz high-speed mode (see my post here), I decided to change my WiFi 2.4GHz to channel 11 and my Hubitat to Zigbee channel 13.

  • Channel 13 - I got impatient waiting for devices to "find" the new channel after changing it, so I sped up the process by manually re-joining them, which went quite smoothly. But then about a week later, when I was trying to re-join a couple of original Xiaomi buttons that I had temporarily moved over to my SmartThings hub for some DTH code testing, my Hubitat just wasn't "seeing" them.
    I also wasn't able to pair a number of other Aqara buttons, including two of the brand new Aqara model WXKG12LM that I had been able to pair with the Hubitat just some days prior. I even tried temporarily changing to a number of other Zigbee channels to see if the devices would repair, but with no success. After another week, after Hubitat staff confirmed there hasn't been any changes in recent hub updates, and I also wasn't able to pair a Securifi Peanut Plug I bought, I decided to reset my ZigBee stick and start all over again.
    Due to a glitch with manual Zigbee Channel selection not working correctly after the stick reset, I landed up on channel 20 (but thinking I had chosen channel 13) and suddenly I was able to pair all the devices that had been refusing to pair. Interestingly, before I had reset the Zigbee stick, I had tried pairing devices with the channel set to 20 with no success. So it seems that something had gone wrong with the configuration or data stored on the Zigbee stick that was only cleared out by resetting it. With channel 20 chosen, I then needed to change my 2.4Ghz WiFi channel again, so I've set it to Channel 1 for the least interference.

  • Channel 20 - It's been about a week, and so far, so good. The Xiaomi buttons and the Peanut plug paired easily, as was re-joining all the other Xiaomi devices and my Sengled bulbs that were still on my Hubitat's device list. Since I now have an XBee that allows me to look at the map of my Zigbee mesh, I will be experimenting with Xiaomi devices connecting through the Peanut Plug (which works as a Zigbee repeater). I'm crossing my fingers that I don't run into the same troubles as mentioned above which required a Zigbee stick reset to get things working again.

Quite the journey youā€™ve been on with your Zigbee devices! Lucky 13 still serving me well, including with the two Xiaomi leak sensors and my new Aqara button. Probably because I donā€™t have that many devices and nothing really that far away from the hub. :man_shrugging:

Thanks for the info @veeceeoh
I had already allocated my router to a fixed channel. Picking 1 as it is out of the zigbee channel 20 range.
Changed my zigbee channel to 22 and re-associated all my Xiaomi devices.
Iā€™ve left ST on channel 20.
Will see how long things remained paired up.
They did stay connected for over a week before they started to gradually drop off.

No matter what I do I cannot get my Xiaomi motion sensors to stay connected. I have about 12 of them an only 1/2 of them stay paired. Iā€™ve tried changing my wifi and zigbee channels based on @veeceeoh charts to ensure there is no interference, reseting the zigbee stick and deleting and re-adding all the devices. But no matter what I try everything drops off. Anyone have luck with 12 or more motion sensors staying connected? When I was using ST they were at least staying on.

I currently only have 4 motion sensors configured, but they seem solid after resetting, changing channels and only pairing them with the Osram Lightify bulbs powered off.

@humac - How long do the motions sensors remain connected before they drop off the network? An hour, or more?

Also did you do a test without repeaters as you mentioned about a week ago?

I know it's frustrating when Xioami devices worked well or better with a SmartThings hub, but the Hubitat isn't identical in terms of hardware and Zigbee setup.

As for the reason Xiaomi devices drop their connection, it is very likely related to "End Device Aging", as explained by Tom Manley, a SmartThings Software Engineer, last year on the ST Community Forums:

As you probably know, the Xiaomi sensors are very sleepy. Most sleepy end devices that we support will wake up every 6 seconds to 2 minutes to check for messages and to make sure its parent knows it is still there. The Xiaomi sensors do this closer to once an hour. That is zigbee compliant behavior so everything is fine so far.

The zigbee specification includes a section called End Device Aging. It states that a parent must forget about a child that doesnā€™t check in for a certain amount of time. In other words if the parent (like the hub or another router on the network) hasnā€™t heard from a device within a certain amount of time it must tell the device to leave and rejoin the network. This isnā€™t an uncommon thing to happens on a zigbee network and most devices will handle this just fine. When the device does it right youā€™ll never even notice it was gone for a brief period.

By using a zigbee sniffer I can see all the communication between the sensor and the hub. The sensor is quiet for about an hour and then sends a checkin message to the hub. The timeout for end devices has elapsed so the hubā€™s zigbee radio doesnā€™t recognize the sensor anymore. Therefore per the specification it sends the sensor a leave and rejoin request. The sensor replies with a message saying it is going to leave and rejoin. Then it does leave but it does not attempt to rejoin. Instead it appears to factory reset itself. This is why it drops offline and I believe is non-compliant behavior.

According to Tom, the SmartThings hub firmware v0.17 did not send a leave and join request - which was probably a bug, and v0.18 of the firmware included an update to the Zigbee stack which likely fixed that and then users saw their Xiaomi devices start dropping their connections.

One of Tom's suggestions as a workaround was to use a Zigbee router (repeater) device:

One thing you can try to get around this issue is to get the device to join through a device other than the hub. Different routers can have different end device timeouts and if you can find one that has a long enough timeout or that doesnā€™t enforce the timeout then the sensor may stay on the network. Youā€™d have to have the sensor far away from the hub and close to routers like outlets or bulbs while you join it.

However, if as he explained, different routers/repeaters have different end device timeouts, it's also possible that routers/repeaters with a timeout less than an hour leads to Xiaomi devices connected to that router/repeater dropping their connections. In other words, some brands of Zigbee repeaters may help keep Xiaomi devices connected while others make things worse.

So in your case, any Motion Sensors connected through your Centralite Plugs may be dropping their connection while the ones connected to the Hubitat remain connected.

Something else important to know with regards to End Device Aging and the end device timeout of the Hub and any repeaters is that "original" Xiaomi devices send their check in message every 60 minutes, while the Aqara devices send it every 50 minutes. This means if your hub or repeater has a end device timeout of 60 minutes, "original" Xiaomi devices are more likely to drop their connection, but it may not be all of them, due to variances in the exact timing of their check in message.

As for the Hubitat hub, I have no idea what its end device timeout is set to or whether it sends a leave and rejoin request to devices that haven't checked in before the timeout - perhaps @mike.maxwell knows? All I do know is that something changed with hub update 698 that resulted in Xiaomi devices remaining connected much more consistently than they were prior to that update, based on my and other users' experiences.

I don't remember what the exact number was, but we did set this to over an hour.
Whilst I haven't done a packet cap on these long enough to see them ignore the rejoin request, based on my experience with one of them, that's appears to be what it's doing.

1 Like

@humac -

Based on @mike.maxwellā€™s reply, my theory is that the problem of some of your 12 Motion Sensors dropping their connection is most likely due to being connected through a Zigbee repeating device which has a end device timeout of less than 60 minutes.

I reset every thing and only paired a single zigbee Xiaomi Aqara Motion device to the hub without any repeaters and this is what the device details show

Create Time 2018-04-18 16:05:28 EDT
Last Update Time 2018-04-18 16:05:41 EDT
Last Activity Time 2018-04-18 16:50:12 EDT

lastCheckin: 1524084551517
lastInactive: 1524084612533
lastMotion: 1524084551604

Iā€™m using the PEQ outlets as repeaters, how can you tell what the end device timeout is?

Are there repeaters that others recommend?

The device driver code creates the inactive event with a countdown timer, so the actual last message sent by the sensor was the same as lastMotion. Using the Epoch Converter webpage, I see that lastMotion was a minute earlier than the Last Activity Time.

So the sensor was online for about 50 minutes, which corresponds to check in interval for Aqara devices. In my experience, then check in message includes the battery voltage data, so if you don't see a battery percentage event, then that check in message was "refused" by the hub or repeater.

Since @mike.maxwell has stated the Hubitat's end device timeout is longer than 1 hour, my deduction is that this Aqara Motion sensor was probably connected through one of your PEQ outlets.

Unfortunately, without an XBee device to map your Zigbee mesh network, the only way to check if an end device is connected through a repeater is through the process of elimination (or if all repeaters are off).

I don't think there's any way to know what the end device timeout is for a repeater device. Maybe contact the manufacturer?

As for recommended repeaters to work with Xiaomi devices, I don't know of any that are 100% recommended. A number of people have been doing experiments / tests with different repeater-capable devices, and posting their findings in this thread.

Also, an XBee device can be used as a repeater, and its end device timeout (known as "Child Poll Timeout") can be user-adjusted, as explained in this post on the SmartThings Community Forums. If you continue reading after that post, you'll see that one person who has a couple XBees is doing some tests to see if his Xiaomi devices maintain their connection through the XBees - but with his SmartThings hub, not Hubitat, of course.

I have an XBee as well, but I haven't had time to do any tests to see if it will work well as a repeater for Xiaomi devices. When I have a chance to do that and also tests with my Securifi Peanut Plug I promise I will report back here.

I want to like these little guys, I really do...

2 Likes

So far, Iā€™ve not had much problems pairing and keeping my Aqara motion sensors connected. But I did have issues when Iā€™ve had ZigBee repeaters. Had to remove them to keep the sensors paired.

However, Iā€™m having issues pairing the Aqara contact sensors. They just will not pair up. They pair almost immediately with ST, but refuses with Hubitat for some reason. Iā€™m not sure if these have different firmware than the Aqara contact sensors that Iā€™ve already paired, but they are a newer purchased set.

I had the same issues with with repeaters. I assumed, since there is so much wifi congestion in my apartment building, forcing the Aqaras to route through Iris plugs would give me a better chance at keeping mine connected. Not so. Direct pairing with the hub seems to be the way to go.

As for your new Aqara contacts, @veeceeoh was helping me with mine yesterday and we found a small issue with his driver, so first, make sure you have the most current one installed. Second, he mentioned he has heard of newer ones being sold through Ali Express that have different firmware. I would reach out to him if you still have issues pairing after following the instructions here.

Ya I really like how small they are. Are you having any luck? I have 12 of them and they all stayed on my ST hub once I unplugged all my zigbee repeater devices and they paired directly to the hub. Tried the same with Hubitat but no dice. Even with only one motion sensor attached to the hub with no other zigbee devices it dropped off.

How far from the hub is the furthers motion sensor for you?

I keep reading this thread and waiting for my Aqara leak sensors and button to drop. They just donā€™t. However, my furthest device is only 12 linear feet away in the basement. I donā€™t have any repeaters, unless the leakSmart valve is acting as one. It might be, I donā€™t really know.

So what I glean from all this is, I should stick to Aqara, and keepā€™m close to the hub. Too bad. I too would really like to ā€œlikeā€ their motion sensors, but they seem to be more trouble than the monetary savings and compact size is worth

I have 2 Aqara motion sensors, and they have not dropped their connection with my Hubitat at all. Based on that, I got two more which just arrived a couple days ago.

I also have a dozen contact sensors, half of the "original" Xiaomi model, and half of the Aqara model. I've not had any problems with pairing either of them to my Hubitat.

However, a couple of weeks ago, I started having issues with pairing three different models of Xiaomi buttons that I previously was able to pair to my Hubitat. I tried changing the Zigbee channel, turning off my WiFi router's 2.4GHz radio and my SmartThings hub, and none of those things helped. Finally I decided to reset my Zigbee stick, which of course removes all Zigbee devices from the mesh, but leaves them all intact in the Hubitat's device list, so they just need to be re-joined (by repeating the same steps as pairing, but you won't see the device appear in the "Discover Devices" page.)

After resetting the Zigbee stick, all of my Xiaomi buttons paired easily again. I reported it to the Hubitat folks, but they aren't sure why the devices started refusing to pair and only a Zigbee stick reset resolved the issue. Either way, you may want to consider resetting the Zigbee stick as a last resort.

Just to check, though, when you say that the Aqara contact sensors refuse to pair with your Hubitat hub, does that mean you never see a Zigbee ID appear while in the "Discover Devices" page of the Hubitat?

Well, it was actually a big issue, because the code that handled open/close messages was not working.

It's important to understand that the device driver does not actually have any effect on the initial pairing process with Zigbee devices, and in the case of Xiaomi devices, it has zero effect on keeping them connected as well. All the device driver does is act as an "interpreter" of messages received from the device, and (if applicable) send commands to the device. Some of those commands may include the configuration of the device after it's paired or to set up how often it sends reports or check in messages. However, Xiaomi devices ignore all reporting configuration commands, and instead send reports only when there is a change, and the regular check-in message (at either 50 or 60 minute intervals, as I've previously mentioned).

I never said there may be a new firmware for a possible new version of the Aqara contact sensors, but since they are relatively simple devices, if there was any change to how they pair with a hub, there's nothing I can do with the device driver code to help with that. Honestly the only change I would expect with a new revision of the Aqara model would be to add temperature reporting and/or switch to an improved magnetic activated contact sensor.

Really, all of the Xiaomi sensors are known not to pair as easily as other Zigbee devices, both with the SmartThings and Hubitat hubs, and it can take repeated attempts.

Since I only have Aqara motion sensors, I have no experience with the "original" Xiaomi model, but it seems really strange that even without any repeaters, it still won't stay connected. This makes me wonder if the end device timeout setting from your PEQ outlets somehow propagates back to the Hubitat hub. Perhaps since you are currently doing testing, trying a reset of the Zigbee stick may be worth a shot.

Just to be clear - I am not advocating for everyone to reset their Zigbee stick as soon as they start having issues with pairing Xiaomi devices or keeping them connected! It was most definitely a last resort measure for me, and just happened to clear up my pairing issues.

1 Like

Mine area all the Aqara models.

So the problematic sensor that drops off the most is definitely the furthest from the hub. Brought the hub closer and its been connected for over 2 hours now. Iā€™m guessing I need to find a repeater that works well with these, as the PEQ outlets I have arenā€™t doing the job. Actually now that I think about it, some of my other Aqara motion sensors were close to the hub but dropped off. Only explanation is that they paired to a close by PEQ outlet.

Iā€™ve tried reseting the zigbee stick also.

How far from the hub is the furthers motion sensor for you?

The furthest sensor is probably around 30 feet, through multiple walls. But I also have other Aqara devices that are about 20 feet past that, and no dropping.

One condition that I had where the motion sensor would drop off is if there's metal between the sensor and the hub. I had one sensor mounted near a closet that had a metal frame, and after pairing it, if I put it at that location, it would drop off.

I will say that in general, it does seems that the Aqara motion sensor is more finicky to staying connected compared to the contact sensors or buttons. Once it's paired and reporting, however, it seems to be doing well.

Not sure if you've tried this, but you could do what I did: pair a sensor, leave it close to the hub for a few days and see if it drops. If it has stayed paired and motion registers, then move it to your final location and then monitor. If it drops afterwards, then there's probably an environmental issue at your location.