-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
Automatically determine the advertising interval for bluetooth devices #79669
Conversation
Hey there @OttoWinter, @jesserockz, mind taking a look at this pull request as it has been labeled with an integration ( |
We should do this for active devices as well, but not for unavailability, just to know when to switch to another adapter on failure |
…ve a better idea when to swtich adapters
Testing
|
Turned out to be smaller than expected. It took a lot more testing time than actual time writing code (but doesn't everything) |
Need to adjust the tests and I think this should be GTG if I don't find anything when adjusting the tests |
Proposed change
Currently we rely on the bluetooth stack to tell us when a device is no longer available. That makes sense for connectable devices, but for devices that do not require an active connection they can sleep for a long time, wake up, broadcast, and go back to sleep to save battery.
To solve this we now collect the maximum time between 16 advertisements and only declare these devices unavailable once we see it miss advertising. If we can't automatically determine the advertising interval we will use the 15m fallback interval currently used for scanners that do not have their own tracking stack (esphome).
This also allows us to have a better metric to determine when advertisements are stale and we should switch adapters when there are multiple adapters for both connectable and non-connectable devices.
fixes #78702
fixes #79178
fixes #78195
fixes #78380
fixes #78261
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
.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: