-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix bluetooth device connection failure when device is seen by dbus but not bleak #83281
Conversation
So this has been a problem since day 1 self.seen_devices = {} is set at scan start so everything already on the bus is missing when we do the unavailable checks we will think the device has disappeared because we don't see it. We need a way to restore self.seen_devices from the global bluez manager when the scanner starts. Probably need to add a utility in bluetooth_adapters or bleak_retry_connector that does that and than we can skip the logic I just added here This is going to solve a lot of unexplained issues Something for tomorrow. |
a457d8b
to
42b43fb
Compare
Still need to test this with switchbots HomeKit devices are working great |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are oyu sure the logic here is correct?
You log if it is LINUX but you return either way (potentially just silencing the error on other platforms).
If this is expected to run in non-Linux envs, why eat the exception in these other cases?
In general you want to restore discoveries after you have connected to the D-Bus signal that will feed you state updates in question, and buffer those updates until after restore discoveries is done. Otherwise code will not be in sync with the latest known states of the devices.
There is no restore on non Linux platforms. It would be slightly more efficient to but the Linux guard first |
We aren't restoring from the bus directly. We are restoring from |
Optimized in 2.10.1 |
Switchbot looks good as well |
Proposed change
Fix devices missing from the bluetooth scanner's
discovered_devices
after restarting scanner by restoring them from the bus after starting the scanner. This ensures the scanner is always in sync with the bus properties and we aren't missing any devices or marking devices unavailable unexpectedly because they were missing as they were seen by the bus before the scanner started.changelog: Bluetooth-Devices/bluetooth-adapters@v0.11.0...v0.12.0
changelog: Bluetooth-Devices/bleak-retry-connector@v2.9.0...v2.10.1
Type of change
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: