How can I debug Aqara Zigbee pairing issues?

I have Aqara door, vibration, motion, and temperature sensors that have worked fine for the past year connected to an Aqara M2 Hub. I’d like to connect them directly to my HA Core instance running on a Mac Mini, rather than going through Aqara and the Homekit Controller integration.

To do this I purchased a Sonoff Plus-E dongle. ZHA auto-detects the serial port path and it appears to be working. However, I can’t get any of the Aqara devices to pair with it.

I’ve read the documentation about pairing difficulties, and various other guides.

I don’t think it’s a signal or interference issue, because the devices are right next to the Sonoff antenna when I try to pair. I understand that pairing in the final location is recommended to avoid later connection issues, but right now I just want one of these to pair at all. If I later run into reliability issues, then I’m happy to troubleshoot signal, interference, routers, etc.

The docs mention that Aqara devices in particular are difficult to pair, but have no suggestions beyond “just keep trying”, which I’ve already done for an hour or so.

Does anyone have a more proactive way to debug? E.g. when I see ZHA activity logging about sent/received frames, is there any way to translate that into something meaningful, which will tell me whether the devices are failing to be seen at all v.s. going to sleep before the pairing is complete?

Especially since the procedure to get the devices into pairing mode isn’t well-documented (in different docs it’s claimed to be a 3-second, 6-second, or 10-second press on the reset button) any data that I can get (e.g. is there a log of raw signals received?) would be helpful.

1 Like

Most likely your Aquara’s are NOT in pairing mode (or still connected to the old Hub.
I have many Aquara devices and all of them are linked without any problem to ZHA.
Debug parameters setups are described in

The old hub is offline, and the devices were unpaired from the Aqara app. It seems quite possible that I didn’t correctly put them into pairing mode. Do you know of any authoritative instructions on how to do that, since the Aqara docs are unclear/inconsistent?

I don’t have the “E” Dongle (“P” version here), but have all the same Aqara sensors and never had a real pairing issue. Occasionally they won’t complete the interview and I have to re-pair, but that’s maybe a 1 in 10 happening.

Putting them into pairing mode has always been simple - press the button for 10 seconds or more and release. I don’t recall the official “hold time” but 10 seconds is what I always use.

They should not need to be “un-paired” first. I have effortlessly moved back and forth between multiple ZHA/z2m installs many times without un-pairing.

Starting with the basics?

  1. Batteries are good
  2. Firmware is current
  3. Dongle is on a reasonable length cable (5ft+) and placed away from any USB3 port.

Some say not to even use a USB3 port. That hasn’t been necessary for me, but use a USB2 port or hub if available, at least as a debug tool.

I place ZHA into pairing mode first, then the DEVICE. It should only take a few seconds.

Have you had success pairing any non-Aqara devices?

EDIT: Had a dumb typo above. I had a “dongle” where I should have had a “device.”

Just push the reset button till the led on the device is flickering.
When flickers it is in pairing mode.
Some devices to pair are described in this post

Thanks @Janneman, those are the clearest instructions that I’ve found yet! According to those, I have been putting the devices into pairing mode correctly. For the door sensor I wasn’t placing the magnet next to the sensor body during pairing, but I tried that and it didn’t make a difference. I see nothing in the logs (enabled debug logging as described in the docs) that looks pairing-specific when I try to pair with any of the devices.

I have only USB3 ports, but I am using an extension cable. But FWIW the M2 Hub, which worked fine, was located in exactly the same place, and I would really not expect this to matter if I’m holding the device a few centimeters away from the antenna. Interference might cause disconnects later, once the devices are moved further away, but it shouldn’t block pairing.

So perhaps there is an issue with the Sonoff dongle. I see no errors in the logs; only a periodically-repeating debug log segment that looks like this:

2022-10-10 12:25:16.345 DEBUG (MainThread) [bellows.ezsp.protocol] Send command readCounters: ()
2022-10-10 12:25:16.347 DEBUG (bellows.thread_0) [bellows.uart] Sending: b'242b21a9a52adca67e'
2022-10-10 12:25:16.364 DEBUG (bellows.thread_0) [bellows.uart] Data frame: b'432ba1a9a52a15b253944a25aa5592499c4e26abecce638bffc66389fc7e3fa7ebcdde6f8fffc7dbd5d2698c4623a9ec763ba5ea758241984c2613b1e070381c0e07bbe5ca6580459a4d9e4f9ff7c3d9d46a35a251904824bdf67e'
2022-10-10 12:25:16.364 DEBUG (bellows.thread_0) [bellows.uart] Sending: b'8520dd7e'
2022-10-10 12:25:16.365 DEBUG (MainThread) [bellows.ezsp.protocol] Application frame 241 (readCounters) received: b'00000a000000000000000000010001000400020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000'
2022-10-10 12:25:16.367 DEBUG (MainThread) [bellows.ezsp.protocol] Send command getValue: (<EzspValueId.VALUE_FREE_BUFFERS: 3>,)
2022-10-10 12:25:16.367 DEBUG (bellows.thread_0) [bellows.uart] Sending: b'352821a9fe2a1631c37e'
2022-10-10 12:25:16.373 DEBUG (bellows.thread_0) [bellows.uart] Data frame: b'5428a1a9fe2a15b3ae215e7e'
2022-10-10 12:25:16.373 DEBUG (bellows.thread_0) [bellows.uart] Sending: b'8610be7e'
2022-10-10 12:25:16.374 DEBUG (MainThread) [bellows.ezsp.protocol] Application frame 170 (getValue) received: b'0001f7'
2022-10-10 12:25:16.375 DEBUG (MainThread) [bellows.zigbee.application] Free buffers status EzspStatus.SUCCESS, value: 247
2022-10-10 12:25:16.375 DEBUG (MainThread) [bellows.zigbee.application] ezsp_counters: [MAC_RX_BROADCAST = 0, MAC_TX_BROADCAST = 10, MAC_RX_UNICAST = 0, MAC_TX_UNICAST_SUCCESS = 0, MAC_TX_UNICAST_RETRY = 0, MAC_TX_UNICAST_FAILED = 0, APS_DATA_RX_BROADCAST = 1, APS_DATA_TX_BROADCAST = 1, APS_DATA_RX_UNICAST = 4, APS_DATA_TX_UNICAST_SUCCESS = 2, APS_DATA_TX_UNICAST_RETRY = 0, APS_DATA_TX_UNICAST_FAILED = 0, ROUTE_DISCOVERY_INITIATED = 0, NEIGHBOR_ADDED = 0, NEIGHBOR_REMOVED = 0, NEIGHBOR_STALE = 0, JOIN_INDICATION = 0, CHILD_REMOVED = 0, ASH_OVERFLOW_ERROR = 0, ASH_FRAMING_ERROR = 0, ASH_OVERRUN_ERROR = 0, NWK_FRAME_COUNTER_FAILURE = 0, APS_FRAME_COUNTER_FAILURE = 0, UTILITY = 0, APS_LINK_KEY_NOT_AUTHORIZED = 0, NWK_DECRYPTION_FAILURE = 0, APS_DECRYPTION_FAILURE = 0, ALLOCATE_PACKET_BUFFER_FAILURE = 0, RELAYED_UNICAST = 0, PHY_TO_MAC_QUEUE_LIMIT_REACHED = 0, PACKET_VALIDATE_LIBRARY_DROPPED_COUNT = 0, TYPE_NWK_RETRY_OVERFLOW = 0, PHY_CCA_FAIL_COUNT = 10, BROADCAST_TABLE_FULL = 0, PTA_LO_PRI_REQUESTED = 0, PTA_HI_PRI_REQUESTED = 0, PTA_LO_PRI_DENIED = 0, PTA_HI_PRI_DENIED = 0, PTA_LO_PRI_TX_ABORTED = 0, PTA_HI_PRI_TX_ABORTED = 0, ADDRESS_CONFLICT_SENT = 0, EZSP_FREE_BUFFERS = 247]

Does that say anything about whether the dongle is or isn’t working?

Unfortunately I don’t have any other Zigbee devices to try this with, except for some Philips Hue bulbs that I don’t want to unpair. In any case they’re apparently difficult to place into pairing mode (I don’t have a switch), so not a great test. Any other way to check whether the dongle is working correctly?

Update: I tried pairing again, without changing anything, and this time the door sensor immediately paired successfully. It has been completely stable for the past day, updating instantly with no dropped updates.

After that success I tried the motion sensor, which also paired immediately. However, after recording its initial values it does not update and eventually becomes unavailable.

The temperature and vibration sensors still won’t pair, even after many more attempts.

So that confirms that the Sonoff dongle is working. I still don’t think that interference is likely, since a) the door sensor has worked perfectly after pairing, despite having been moved farther from the antenna, b) the motion sensor had a strong -38 RSSI before going unavailable. The entire time from pairing to going unavailable it was 1.5m away from the antenna, with only air in between, c) I have the dongle on a 3m USB2 extension cable, and placed up high and reasonably far from other RF sources.