From 98d93ae563a711ce0929da65af8dfd791864d34f Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 16 Sep 2022 20:34:34 -0500 Subject: [PATCH] Change signature of async_track_unavailable callback to provide additional information (#1470) --- ...09-16-bluetooth-unavailable-api-changes.md | 19 +++++++++++++++++++ docs/bluetooth.md | 4 ++-- 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 blog/2022-09-16-bluetooth-unavailable-api-changes.md diff --git a/blog/2022-09-16-bluetooth-unavailable-api-changes.md b/blog/2022-09-16-bluetooth-unavailable-api-changes.md new file mode 100644 index 00000000..4e1d2a30 --- /dev/null +++ b/blog/2022-09-16-bluetooth-unavailable-api-changes.md @@ -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) +``` + diff --git a/docs/bluetooth.md b/docs/bluetooth.md index 254d23a3..c9403786 100644 --- a/docs/bluetooth.md +++ b/docs/bluetooth.md @@ -118,8 +118,8 @@ If the `connectable` argument is set to `True`, if any `connectable` controller ```python from homeassistant.components import bluetooth -def _unavailable_callback(address: str) -> None: - _LOGGER.debug("%s is no longer seen", address) +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) ```