fix: keep direct Bluetooth on local BlueZ - #19
Open
Chreece wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
When a Philips shaver was visible through both the Home Assistant host Bluetooth adapter and a standard ESPHome Bluetooth proxy, choosing Direct Bluetooth did not guarantee that the host adapter was used. Home Assistant could re-select the stronger proxy when opening the connection.
Philips shavers use LE Secure Connections and their Bluetooth bond belongs to the adapter that paired them. As a result, a shaver could be correctly paired and trusted on hci0, while setup still failed because the actual connection was silently attempted through an ESPHome proxy that cannot complete the required pairing.
There was also a second setup issue: manually selecting the shaver could race with Home Assistant's automatic Bluetooth discovery for the same device and show “Configuration flow is already in progress”, even though the user had intentionally started the setup.
What this fixes
Direct Bluetooth now stays on a local Home Assistant/BlueZ adapter whenever one is available, instead of allowing a stronger standard Bluetooth proxy to take over the connection. Runtime polling follows the same local path.
Manual setup also no longer aborts simply because an automatic discovery flow for the same shaver exists; an actually configured duplicate is still rejected normally.
The behavior was tested with a Philips OneBlade 360 QP4530, paired/bonded/trusted on BlueZ, while standard ESPHome Bluetooth proxies remained online. Before the fix the proxy took over and setup failed; after the fix the device was selected through hci0 and setup completed successfully.