From 39ac658f8b97de967efd97b0ba53d349c440eb30 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 29 Aug 2022 09:21:55 -0500 Subject: [PATCH] Document bluetooth.async_scanner_count (#1452) --- docs/network_discovery.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/network_discovery.md b/docs/network_discovery.md index 39579a69..f21bf645 100644 --- a/docs/network_discovery.md +++ b/docs/network_discovery.md @@ -104,6 +104,17 @@ from homeassistant.components import bluetooth scanner = bluetooth.async_get_scanner(hass) ``` + +### Determine if there is scanner running + +The Bluetooth integration may be set up but has no connectable adapters or remotes. The `bluetooth.async_scanner_count` API can be used to determine if there is a scanner running that will be able to receive advertisements or generate `BLEDevice`s that can be used to connect to the device. An integration may want to raise a more helpful error during setup if there are no scanners that will generate connectable `BLEDevice` objects. + +```python +from homeassistant.components import bluetooth + +count = bluetooth.async_scanner_count(hass, connectable=True) +``` + ### Subscribing to unavailable callbacks To get a callback when the Bluetooth stack can no longer see a device, call the `bluetooth.async_track_unavailable` API. For performance reasons, it may take up to five minutes to get a callback once the device is no longer seen.