Xiaomi & Aqara Devices - Pairing & Keeping them connected

Ahhh half my xiaomi sensors dropped off... ugh.. @veeceeoh what are your settings to keep the sensors from dropping off?

channel 26 is a low powered channel so you will not get the maximum power (PL setting 4).
Give this thread a read at SmartThings
You could also move all your 2.4 wifi channels on your home routers away from the hub channel range.

I did this, i moved hubitat to channel 23 and my wifi is on channel 1

did you try setting EO to 1 and KY to 5a6967426565416c6c69616e63653039
then pairing the sensors?
Sorry not home and the online manual is not working.

@veeceeoh I got another Xbee3 today to play with I didn't want to remove and re-pair my other Xbee3 as I was doing a long term test with them.
But you are correct JV can be set to 1 and then paired it was just a coincidence (and doing to many things at the same time) that I had it set to 0 and then set to 1 and it paired.
Also my settings above also had PL set to 1 and it should have been 4 (max power) I have updated the file linked above.

Nothing special outside the recommendations from the Zigbee - from flakey to stable thread on the ST Community Forums.

The specific setting values that help prevent Xiaomi devices from dropping their connections due to end device aging timeout are:

SP (Sleep period) = AF0 (2800 milliseconds)
SN (Number of sleep periods) = 130

You said you change those settings, although after pairing the XBee when they should have been fine to change before pairing, and your Xiaomi devices remained connected for over 24 hours, so I think they made it past the max sleep time of 3 * SP * SN (3 * 28 seconds * 130 periods = 182 minutes), and the dropped connection by half of the devices is related to something else.

The best way to confirm that Xiaomi devices are staying connected past the end device sleep timeout period is by looking for battery report events occurring every 50 or 60 minutes. Sometimes the first or first two battery reports may be missed, but if there is a battery report within 3 hours after pairing and regularly occurring afterwards, then the Xiaomi device is maintaining its connection.

Exactly true. That KY (Encryption Key value) of 5A6967426565416C6C69616E63653039 is used by all Zigbee HA (Home Automation) devices, but the XCTU software will blank out the KY box as soon as you write that setting to the Zigbee module, to keep it secure.

Definitely before you pair an XBee to your hub's network, security needs to be enabled by setting EE = 1 and the above Zigbee HA key value written to the KY setting. Also, make sure that EO = 1 (Send unencrypted network key for Zigbee network join)

Besides enabling encryption and setting the key, API mode must be enabled and set up for use with Zigbee HA via these settings:

AP = 1 (API operating mode enabled )
AO = 3 (API Output Mode = explicit with ZDO passthrough )
ZS = 2 (Zigbee Stack Profile = ZigBee-PRO )

Note that ST user @mckenph quoted user @TN_Oldman using these API mode related settings with success:

AP = 2 (API operating mode enabled with escaped characters )
AO = 7 (Not sure about this value because the Digi documentation only lists values of 0, 1, or 3)
ZS = 2 (Zigbee Stack = ZigBee-PRO )

Either way, all of those settings would need to be written to the module before pairing it with your hub.

I agree with @NoWon that the transmit power level should be set to the max, and if you don't care about power draw of the Bee module, then Boost mode should be enabled:

PL = 4 (Power Level = +5 dBm for XBee w/Boost disabled, +18dBm for Bee-Pro w/Boost enabled)
PM = 1 (Power Mode = Boost mode enabled )

Another setting to look at is Node Join Time (NJ). As I understand it, according to the DIGI Documentation on Permit Joining for a XBee set as a router, after the XBee router joins a network, a timer starts, during which it allows end devices to join. Set to any value below 0xFF, the Node Join Time timer is set to that many seconds.

In @NoWon's setting file and in other user's recommendations elsewhere, NJ is set to 0x5A, equal to 90 seconds. After the timer is finished, the router does not allow device joining even if the power-cycled or reset. The only things that restart the timer are writing a new NJ value, pressing the commissioning button twice (if your XBee host board has one!), or sending a CB = 2 command (the software method of pressing the commissioning button twice).

I have no idea how turning on commissioning on the coordinator (i.e., Discover Devices on your Hubitat) affects the XBee when functioning as a router, but presumably by doing that it tells the XBee to allow end devices to join. Either way, if NJ is set to 0xFF (the default value) then the timer is disabled and joining is permanently enabled. This setting may or may not help Xiaomi devices to rejoin in the event they are booted off for a reason other than end device aging timeout.

You also mentioned troubles with Hubitat initializing the paired connection with your Bee, so you may want to have a look at this DIGI docs page on XBee Zigbee router joining. It confirms that there are setting values which need to be properly set and written before attempting to join an XBee router to a Zigbee network.

The last thing I want to mention that could cause an XBee to stop working as expected and/or drop connections of end devices that joined through that XBee is that if you change and write a new ZS value or any security command values after an XBee router has joined a network, it will leave that network. See this DIGI docs page for more info. So if you made any changes to the security command values or even entered and wrote the KY encryption key value after your XBee was connected to your Hubitat, that may explain why some devices dropped their connection.

2 Likes

could the xbee module be directly connected to the hubitat hub for power and still work fine for this?

thank you.

On my list of things to test but have not tried yet.
Will give it a shot in over the next few days hopefully. (work is crazy busy)

1 Like

Wow thanks for the detailed posting. I'll give this all a try tomorrow and rebuild the network again... ugh getting tired of rejoining 40 devices everytime.. Hopefully soon it will not happen again...

so i was having trouble with my xiaomi devices staying connected ... this is in spite of having zigbee repeaters all over the place, moving my 2.4 wifi to channel 1 and using the zigbee channel 18 where ST is channel 24. been trying different things for the last month or so. heres what seems to have helped for me:

  1. get and save the driver code from the main post in this thread
  2. start discover devices
  3. put xiaomi device in pairing mode
    -- release button soon as device indicator light starts blinking
  4. wait for device to show up in list of discovered devices
  5. if devices details for the discovered device show as unknown (manufacturer and other details)
    -- stop discovery
    -- delete device named device
    -- go to step #2
  6. enjoy!

edit: should have mentioned these are aqara devices.

1 Like

@veeceeoh you said you have the xiaomi temp/humidity sensors? Are they the aqara ones?

I have the aqara ones and I read somewhere they corrupt the network.

So I did a test and removed all the aqara temp/humidity sensors and sure enough with in 24 hrs all my xiaomi Motion sensors came back online.

I need to find that thread and see why this is the case!

I have aqara xiaomi temp/humidity sensor and both original and aqara motion sensors and once I routed them correctly I have not had any issues.

Just a note about boost mode...

It's fine to use that in the US.

For anyone who is in the U.K. Or EU, though, that will transmit above the power level allowed by law for unlicensed devices. So just something to be aware of.

I wish I saw this thread last week instead of pulling out my hair trying to figure out how to stabalize my xiaomi devices.

I can convirm the Centralite (aka Iris) plugs are a problem. I had 3 of them installed and had nothing but endless problems with devices dropping off.

However I did install multiple Sylvania Smart Plugs (non A) and since then all 34 of my devices have been reporting in on the hour (some would be a little late but eventually hit within the next hour). They have been rock solid for the past two days.

For my WiFi I have an eero setup and I read that it uses channels 1 and 6. So I did a reset of my zigbee stick and I guess hubitat looks for a good channel at this point. It set it to 23 which is outside the eero range from the looks of it.

I'm going to watch it a bit more, do some uplugging and testing and see how it goes. But if all holds up I'm going to add one more plug to help with the mesh a bit more and hopefully never have to fight with these things again.

Now I have to scan through the thread to try and figure out what I need to see my mesh. I really want to dive into that and see it.

1 Like

I have 4 Aqara Temp/Humidity sensors and 2 "original" Xiaomi T/H sensors. I have not noticed any issues due to them being on my network. Since I changed to Channel 20 and added my first XBee (now there are two), I haven't any dropped connected except when I was doing electrical work and had to cut power in my home. So outside of that, there's been two months of stability for a majority of my devices and over a month for the remainder (from when I was doing testing with routing through my Peanut Plug and the XBee.

Good to know, and thanks for drawing from your wide range of knowledge as usual!

What you need is an XBee zigbee module, and as a bonus on top of being able to map your mesh network, it can serve as a dependable router (repeater) for Xiaomi devices, based on my and many others' experiences.

1 Like

which antenna are you using with xbee module?

thank you.

I am just using some old 2.4 wifi antennas I had laying around . One I bought 20 years ago is a 12 dBi and the others are just 5 dBi ones from old wifi routers. Then the fourth Xbee3 (XB3-24Z8PT) has just a built in pcb trace antenna.

1 Like

got it.

don't have any of the wifi antennas lying around. get a bit confused with antenna connectors. what connector should I look for if buying one of the ones with the antenna push in type on board from mouser?

thank you.

edit: one of them seem to have the good old screw in wifi antenna so that might solve that.

what are folks using to power the xbee?

thank you.

Sorry I do not have any U.FL antenna units but looks like for those you need an antenna with a U.FL connector or you can get an adapter to SMA.
My XB3-24Z8ST have an SMA connection which is what most wifi routers use for their wifi antennas.

For power I use my usb XBEE grove dev adaptor board that way I can just use a usb wall plug to power them or use a usb battery pack to make them portable.

1 Like

I finally got my XBee up and running to scan the network. I'm seeing this as well though. I can't see any end devices that are connected through the sylvania plugs. Were you able to get around this or is it just not going to work?

Download the Hubitat app