bleak icon indicating copy to clipboard operation
bleak copied to clipboard

Add support for pairing callbacks

Open tgagneret-embedded opened this issue 1 month ago • 3 comments

Add support for pairing callbacks.

This is based on:

  • https://github.com/hbldh/bleak/pull/1133
  • https://github.com/hbldh/bleak/pull/1100

tgagneret-embedded avatar Nov 28 '25 14:11 tgagneret-embedded

@tgagneret-embedded Thanks for picking this back up. We have a lot of Home Assistant users who are really excited about having this feature. As soon as this gets going, I'll work on adding support to ESPHome as well.

bdraco avatar Dec 03 '25 15:12 bdraco

FYI @dlech , I drafted a PR to remove the duplicate code for pairing. I need to test the "Just works" pairing, I'm not sure I have a device to do test this.

https://github.com/hbldh/bleak/pull/1868

tgagneret-embedded avatar Dec 09 '25 18:12 tgagneret-embedded

@tgagneret-embedded I opened a PR against your feature/pairing branch with the changes that @dlech requested here (except the one about moving the _pair method into a separate PR). Hope that helps.

https://github.com/tgagneret-embedded/bleak/pull/1

EuleMitKeule avatar Dec 10 '25 01:12 EuleMitKeule

Codecov Report

:x: Patch coverage is 43.70861% with 85 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 34.98%. Comparing base (38892ff) to head (f76bda0).

Files with missing lines Patch % Lines
bleak/backends/bluezdbus/agent.py 41.22% 67 Missing :warning:
bleak/backends/bluezdbus/client.py 23.52% 13 Missing :warning:
bleak/backends/corebluetooth/client.py 0.00% 1 Missing and 1 partial :warning:
bleak/backends/winrt/client.py 0.00% 1 Missing and 1 partial :warning:
bleak/backends/bluezdbus/manager.py 50.00% 1 Missing :warning:
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1864      +/-   ##
===========================================
+ Coverage    34.60%   34.98%   +0.37%     
===========================================
  Files           37       39       +2     
  Lines         3849     3993     +144     
  Branches       476      484       +8     
===========================================
+ Hits          1332     1397      +65     
- Misses        2490     2567      +77     
- Partials        27       29       +2     
Flag Coverage Δ
macos-latest-py3.10 16.95% <7.94%> (-0.33%) :arrow_down:
macos-latest-py3.11 16.95% <7.94%> (-0.33%) :arrow_down:
macos-latest-py3.12 16.95% <7.94%> (-0.33%) :arrow_down:
macos-latest-py3.13 16.95% <7.94%> (-0.33%) :arrow_down:
macos-latest-py3.14 16.72% <7.94%> (-0.33%) :arrow_down:
ubuntu-latest-py3.10 23.11% <43.70%> (+0.82%) :arrow_up:
ubuntu-latest-py3.11 23.11% <43.70%> (+0.82%) :arrow_up:
ubuntu-latest-py3.12 23.11% <43.70%> (+0.82%) :arrow_up:
ubuntu-latest-py3.13 23.11% <43.70%> (+0.82%) :arrow_up:
ubuntu-latest-py3.14 21.19% <43.70%> (+0.91%) :arrow_up:
windows-latest-py3.10 16.90% <7.94%> (-0.33%) :arrow_down:
windows-latest-py3.11 16.90% <7.94%> (-0.33%) :arrow_down:
windows-latest-py3.12 16.90% <7.94%> (-0.33%) :arrow_down:
windows-latest-py3.13 16.90% <7.94%> (-0.33%) :arrow_down:
windows-latest-py3.14 16.61% <7.94%> (-0.32%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Dec 15 '25 12:12 codecov[bot]

@tgagneret-embedded I opened a PR against your feature/pairing branch with the changes that @dlech requested here (except the one about moving the _pair method into a separate PR). Hope that helps.

tgagneret-embedded#1

I'm not sure why you changed https://github.com/tgagneret-embedded/bleak/pull/1/files#diff-aaae8a8eb8ab5923670dec887dfaf4d90aacacf551882aab9a51165920eae38d but I reverted it back since it does not work. Could you give me more detail to make sure it works correctly ?

Thanks

tgagneret-embedded avatar Dec 15 '25 12:12 tgagneret-embedded

@tgagneret-embedded I opened a PR against your feature/pairing branch with the changes that @dlech requested here (except the one about moving the _pair method into a separate PR). Hope that helps. tgagneret-embedded#1

I'm not sure why you changed https://github.com/tgagneret-embedded/bleak/pull/1/files#diff-aaae8a8eb8ab5923670dec887dfaf4d90aacacf551882aab9a51165920eae38d but I reverted it back since it does not work. Could you give me more detail to make sure it works correctly ?

Thanks

@dlech requested this change in this review comment: https://github.com/hbldh/bleak/pull/1864#discussion_r2572255647 The _get_device_property does the same thing as the method in question, but throws more helpful error messages in case of keys not being found in the dictionaries. But it's possible I might have done something wrong when refactoring. I'll have another look.

EuleMitKeule avatar Dec 15 '25 12:12 EuleMitKeule

@tgagneret-embedded I opened a PR against your feature/pairing branch with the changes that @dlech requested here (except the one about moving the _pair method into a separate PR). Hope that helps. tgagneret-embedded#1

I'm not sure why you changed https://github.com/tgagneret-embedded/bleak/pull/1/files#diff-aaae8a8eb8ab5923670dec887dfaf4d90aacacf551882aab9a51165920eae38d but I reverted it back since it does not work. Could you give me more detail to make sure it works correctly ? Thanks

@dlech requested this change in this review comment: #1864 (comment) The _get_device_property does the same thing as the method in question, but throws more helpful error messages in case of keys not being found in the dictionaries. But it's possible I might have done something wrong when refactoring. I'll have another look.

I understand, maybe the naming is not correct. In my case I get the complete Device1 and not only one property of Device1.

tgagneret-embedded avatar Dec 15 '25 12:12 tgagneret-embedded

@tgagneret-embedded I opened another PR based on your current feature/pairing branch. It should now reuse the _get_device_property method correctly for the Address and Alias attributes. https://github.com/tgagneret-embedded/bleak/pull/2

EuleMitKeule avatar Dec 15 '25 13:12 EuleMitKeule

@tgagneret-embedded I opened another PR based on your current feature/pairing branch. It should now reuse the _get_device_property method correctly for the Address and Alias attributes. tgagneret-embedded#2

https://github.com/hbldh/bleak/pull/1864#discussion_r2619338870

tgagneret-embedded avatar Dec 15 '25 13:12 tgagneret-embedded