Change signature of async_track_unavailable callback to provide additional information (#1470)

This commit is contained in:
J. Nick Koston 2022-09-16 20:34:34 -05:00 committed by GitHub
parent dd9cb2a28f
commit 98d93ae563
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 2 deletions

View File

@ -0,0 +1,19 @@
---
author: J. Nick Koston
authorURL: https://github.com/bdraco
title: "Bluetooth async_track_unavailable API changes for 2022.10"
---
For Home Assistant Core 2022.10 we have changed the `async_track_unavailable` bluetooth API to send the last `BluetoothServiceInfoBleak` to the callback instead of the `address`.
Below is a new example of the usage:
```python
from homeassistant.components import bluetooth
def _unavailable_callback(info: bluetooth.BluetoothServiceInfoBleak) -> None:
_LOGGER.debug("%s is no longer seen", info.address)
cancel = bluetooth.async_track_unavailable(hass, _unavailable_callback, "44:44:33:11:23:42", connectable=True)
```

View File

@ -118,8 +118,8 @@ If the `connectable` argument is set to `True`, if any `connectable` controller
```python ```python
from homeassistant.components import bluetooth from homeassistant.components import bluetooth
def _unavailable_callback(address: str) -> None: def _unavailable_callback(info: bluetooth.BluetoothServiceInfoBleak) -> None:
_LOGGER.debug("%s is no longer seen", address) _LOGGER.debug("%s is no longer seen", info.address)
cancel = bluetooth.async_track_unavailable(hass, _unavailable_callback, "44:44:33:11:23:42", connectable=True) cancel = bluetooth.async_track_unavailable(hass, _unavailable_callback, "44:44:33:11:23:42", connectable=True)
``` ```