From 7dbd066c184aa8f0a0f227d6c463a43f7d8de059 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 26 Dec 2023 21:48:48 -1000 Subject: [PATCH] Remove Bluetooth best practices that are now automatically handled (#2024) --- docs/bluetooth.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/docs/bluetooth.md b/docs/bluetooth.md index d4729e16..eea7f6d8 100644 --- a/docs/bluetooth.md +++ b/docs/bluetooth.md @@ -7,14 +7,10 @@ sidebar_label: "Building a Bluetooth Integration" - Integrations that need to use a Bluetooth adapter should add `bluetooth_adapters` in [`dependencies`](creating_integration_manifest#dependencies) in their [`manifest.json`](creating_integration_manifest). The [`manifest.json`](creating_integration_manifest) entry ensures that all supported remote adapters are connected before the integration tries to use them. -- When connecting to Bluetooth devices with `BleakClient`, always use the `BLEDevice` object instead of the `address` to avoid the client starting a scanner to find the `BLEDevice`. Call the `bluetooth.async_ble_device_from_address` API if you only have the `address`. - - Call the `bluetooth.async_get_scanner` API to get a `BleakScanner` instance and pass it to your library. The returned scanner avoids the overhead of running multiple scanners, which is significant. Additionally, the wrapped scanner will continue functioning if the user changes the Bluetooth adapter settings. - Avoid reusing a `BleakClient` between connections since this will make connecting less reliable. -- Fetch a new `BLEDevice` from the `bluetooth.async_ble_device_from_address` API each time a connection is made. Alternatively, register a callback with `bluetooth.async_register_callback` and replace a cached `BLEDevice` each time a callback is received. The details of a `BLEDevice` object may change due to a change in the active adapter or environment. - - Use a connection timeout of at least ten (10) seconds as `BlueZ` must resolve services when connecting to a new or updated device for the first time. Transient connection errors are frequent when connecting, and connections are not always successful on the first attempt. The `bleak-retry-connector` PyPI package can take the guesswork out of quickly and reliably establishing a connection to a device. ### Connectable and non-connectable Bluetooth controllers