Skip to content

Drop bleak_scanner_instance; construct BleakScanner internally#552

Open
bdraco wants to merge 3 commits intomainfrom
drop-bleak-scanner-instance
Open

Drop bleak_scanner_instance; construct BleakScanner internally#552
bdraco wants to merge 3 commits intomainfrom
drop-bleak-scanner-instance

Conversation

@bdraco
Copy link
Copy Markdown
Collaborator

@bdraco bdraco commented Apr 21, 2026

bleak removed register_detection_callback, so the detection callback must now be passed via the BleakScanner constructor. There is no way to add it after construction, so accepting an already-built scanner no longer works.

Drop the bleak_scanner_instance parameter from Controller and BleController entirely and always construct BleakScanner(detection_callback=self._device_detected) internally in BleController.async_start. Also drop the now-unused register_detection_callback(None) call from async_stop.

This is safe for Home Assistant because habluetooth already overwrites BleakScanner by the time we construct it, so the internally-created scanner is the HA-managed one.

This is a breaking change to the Controller signature, but it is forced by the upstream bleak removal; there is no compatible alternative.

bdraco added 3 commits April 21, 2026 08:19
bleak removed register_detection_callback, so the detection callback
must now be passed via the BleakScanner constructor. Accepting an
already-built scanner no longer works.

Drop the bleak_scanner_instance parameter from Controller and
BleController entirely and always construct BleakScanner internally
with detection_callback=self._device_detected.

This is a breaking change to the Controller signature, but there is
no compatible alternative given the upstream bleak removal.
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 21, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.13%. Comparing base (48b0280) to head (63db32d).

Files with missing lines Patch % Lines
aiohomekit/controller/ble/controller.py 12.50% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #552      +/-   ##
==========================================
- Coverage   75.21%   75.13%   -0.09%     
==========================================
  Files         100      100              
  Lines        9580     9563      -17     
==========================================
- Hits         7206     7185      -21     
- Misses       2374     2378       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bdraco bdraco marked this pull request as ready for review April 21, 2026 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant