mirror of
https://github.com/home-assistant/developers.home-assistant.git
synced 2025-07-23 17:26:29 +00:00
Document async_track_unavailable in bluetooth (#1408)
This commit is contained in:
parent
ae24119e77
commit
e998f5b7c6
@ -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`
|
### 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.
|
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.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user