Xiaomi & Aqara Devices - Pairing & Keeping them connected

How did you determine that JV (coordinator channel verification) needs to be turned on after pairing instead of before?

It was suggested by member exile on this SmartThings thread and worked for me.
I am sure you can run without changing the JV just better to set it. Maybe it will pair with it already set but I do not believe it would for me but that was more than three weeks ago.

@humac that is odd not sure how you joined with out at least the key
EO must be 1 and KY must be 5a6967426565416c6c69616e63653039
are you able to scan your network and see you other zigbee devices?

my Xbee3 are the pro version but that should not matter as they are just higher power rating

ok I just got home and took a look at the file for some reason the Xbee3 did not have the ky value 5a6967426565416c6c69616e63653039 in the file
I read both of my Xbee and it does not appear on either of them so I tried writing it to the Xbee3 again and it appeared to work but when I read them the key was blank again.
maybe is unreadable for security.
Which may explain why it would not pair for you with my settings.
Just looked in the manual and the KY is a write only value which explains why it didn't save into my file after I read the Xbee3 settings and saved them.

sorry about that my bad
I updated the download link with the proper key settings and JV set to 1 maybe it will work with JV set to 1 It may have just been a coincidence that both of mine paired after setting JV to 0 then put JV back to 1

Ya I was able to join and scan and see my network without setting those values.

interesting the way I read the manual the correct key is required
If the coordinator (Hubitat) uses a preconfigured link key (KY > 0), then the coordinator will not send the network key unencrypted to joining devices. Only devices with the correct preconfigured link key can able to join and communicate on the network.

Can you get other end devices to route through the Xbee3?

Ya I’m currently testing my 18 xiaomi devices before i add the rest of my ST sensors but about 9 are paired to the hub and 9 are paired to the XBee3. According to XTCU I can see the mapping and that’s what it shows.

How do you know what the Hubitat key is and is it the same for all hubitat hubs?

From what i read it is a standard publicly available HA (home automation) key used for all home automation devices.

So since adding the Xbee3 to my Hubitat hub my 20 Xiaomi sensors and 20 other zigbee devices have all stayed on for 24hrs. Before the Xiaomi sensors were dropping off after a few mins.

1 Like

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!