Try next mDNS address on Pair-Verify IncorrectPairingIdError#572
Try next mDNS address on Pair-Verify IncorrectPairingIdError#572bluetoothbot wants to merge 2 commits into
Conversation
Some buggy accessories (e.g. the BTicino Smarther 2 / XW8002) advertise other devices' IP addresses in their mDNS record, with rotating order on each re-announcement. The first advertised address can belong to a different physical accessory that connects fine at the TCP layer but returns its own pairing id during Pair-Verify step 3, raising IncorrectPairingIdError. Previously the reconnect loop retried the same address indefinitely and never reached the correct one. SecureHomeKitConnection now skips an address that fails Pair-Verify with IncorrectPairingIdError and tries the next advertised address, only propagating the error once every address has been exhausted. The base HomeKitConnection._connect_once() gains an exclude_hosts parameter so the offending address is removed before the next TCP attempt. Closes Jc2k#571 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
PR Review — Try next mDNS address on Pair-Verify IncorrectPairingIdErrorSolid, well-scoped fix for the rotating-mDNS-address bug; one robustness gap around loop termination is worth addressing before merge. Strengths:
Needs attention:
🟡 Important
1. Loop can hammer the wrong device forever if connected_host isn't found in self.hosts
|
Rebase with requested adjustmentsBranch Changes applied
StatsActions performed
CI statusCI will be checked asynchronously. Automated by Kōan |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #572 +/- ##
==========================================
+ Coverage 75.21% 75.45% +0.23%
==========================================
Files 100 101 +1
Lines 9580 9683 +103
==========================================
+ Hits 7206 7306 +100
- Misses 2374 2377 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
Some buggy HAP accessories (e.g. the BTicino Smarther 2 / XW8002) advertise other devices' IP addresses in their mDNS
addresseslist, with rotating order on each announcement. When the first address belongs to a different physical accessory, it connects fine at the TCP layer but returns its own pairing id during Pair-Verify step 3, raisingIncorrectPairingIdError. The reconnect loop previously retried the same address forever and never reached the correct one. This makes the connection skip an address that fails Pair-Verify and try the next advertised address.Closes #571
Changes
SecureHomeKitConnection._connect_once()now loops over advertised addresses: onIncorrectPairingIdErrorit excludes the offending address and retries the next one, only propagating the error once all addresses are exhausted.HomeKitConnection._connect_once()gains anexclude_hostsparameter so the bad address is removed before the next TCP attempt._pair_verify()for the retry loop.Test plan
tests/test_ip_connection.pycovers:exclude_hostsfiltering, address fallback onIncorrectPairingIdError, and error propagation once all addresses are exhausted.Quality Report
Changes: 2 files changed, 177 insertions(+), 5 deletions(-)
Code scan: clean
Tests: failed (FAILED)
Branch hygiene: 1 issue(s)
Generated by Kōan