diff --git a/docs/network_discovery.md b/docs/network_discovery.md index d986ae36..b9bc7c67 100644 --- a/docs/network_discovery.md +++ b/docs/network_discovery.md @@ -77,6 +77,20 @@ entry.async_on_unload( ) ``` + +### 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. + +```python +from homeassistant.components import bluetooth + +def _unavailable_callback(address: str) -> None: + _LOGGER.debug("%s is no longer seen", address) + +cancel = bluetooth.async_track_unavailable(hass, _unavailable_callback, "44:44:33:11:23:42") +``` + ### Fetching the bleak `BLEDevice` from the `address` Integrations wishing to avoid the overhead of starting an additional scanner to resolve the address may call the `bluetooth.async_ble_device_from_address` API, which returns a `BLEDevice` if the `bluetooth` integration scanner has recently seen the device. Integration MUST fall back to connecting via the `address` if the `BLEDevice` is unavailable.