From fbdef7f5cdf7aead17df24a34b0dde1f8fb7e54e Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 18 Apr 2024 09:37:20 -0500 Subject: [PATCH] Bump habluetooth to 2.8.0 (#115789) * Bump habluetooth to 2.8.0 Adds support for recovering some adapters that fail to initialize due to kernel races * bump lib * tweak --- homeassistant/components/bluetooth/__init__.py | 13 ++----------- homeassistant/components/bluetooth/diagnostics.py | 2 +- homeassistant/components/bluetooth/manifest.json | 2 +- homeassistant/package_constraints.txt | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 6 files changed, 7 insertions(+), 16 deletions(-) diff --git a/homeassistant/components/bluetooth/__init__.py b/homeassistant/components/bluetooth/__init__.py index 35fbeb2f3b3..35d4b625942 100644 --- a/homeassistant/components/bluetooth/__init__.py +++ b/homeassistant/components/bluetooth/__init__.py @@ -53,7 +53,6 @@ from homeassistant.loader import async_get_bluetooth from . import models, passive_update_processor from .api import ( - _get_manager, async_address_present, async_ble_device_from_address, async_discovered_service_info, @@ -130,13 +129,6 @@ _LOGGER = logging.getLogger(__name__) CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN) -async def _async_get_adapter_from_address( - hass: HomeAssistant, address: str -) -> str | None: - """Get an adapter by the address.""" - return await _get_manager(hass).async_get_adapter_from_address(address) - - async def _async_start_adapter_discovery( hass: HomeAssistant, manager: HomeAssistantBluetoothManager, @@ -303,17 +295,16 @@ async def async_update_device( async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up a config entry for a bluetooth scanner.""" + manager: HomeAssistantBluetoothManager = hass.data[DATA_MANAGER] address = entry.unique_id assert address is not None - adapter = await _async_get_adapter_from_address(hass, address) + adapter = await manager.async_get_adapter_from_address_or_recover(address) if adapter is None: raise ConfigEntryNotReady( f"Bluetooth adapter {adapter} with address {address} not found" ) - passive = entry.options.get(CONF_PASSIVE) mode = BluetoothScanningMode.PASSIVE if passive else BluetoothScanningMode.ACTIVE - manager: HomeAssistantBluetoothManager = hass.data[DATA_MANAGER] scanner = HaScanner(mode, adapter, address) scanner.async_setup() try: diff --git a/homeassistant/components/bluetooth/diagnostics.py b/homeassistant/components/bluetooth/diagnostics.py index a45500265cf..1c9c9a56b2e 100644 --- a/homeassistant/components/bluetooth/diagnostics.py +++ b/homeassistant/components/bluetooth/diagnostics.py @@ -10,7 +10,7 @@ from bluetooth_adapters import get_dbus_managed_objects from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant -from . import _get_manager +from .api import _get_manager async def async_get_config_entry_diagnostics( diff --git a/homeassistant/components/bluetooth/manifest.json b/homeassistant/components/bluetooth/manifest.json index f7d27e84a17..b41c344bdf2 100644 --- a/homeassistant/components/bluetooth/manifest.json +++ b/homeassistant/components/bluetooth/manifest.json @@ -20,6 +20,6 @@ "bluetooth-auto-recovery==1.4.1", "bluetooth-data-tools==1.19.0", "dbus-fast==2.21.1", - "habluetooth==2.7.0" + "habluetooth==2.8.0" ] } diff --git a/homeassistant/package_constraints.txt b/homeassistant/package_constraints.txt index 7782fba1713..7f134b1a93d 100644 --- a/homeassistant/package_constraints.txt +++ b/homeassistant/package_constraints.txt @@ -28,7 +28,7 @@ dbus-fast==2.21.1 fnv-hash-fast==0.5.0 ha-av==10.1.1 ha-ffmpeg==3.2.0 -habluetooth==2.7.0 +habluetooth==2.8.0 hass-nabucasa==0.78.0 hassil==1.6.1 home-assistant-bluetooth==1.12.0 diff --git a/requirements_all.txt b/requirements_all.txt index 0e11345c278..18c4d6a0076 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1029,7 +1029,7 @@ ha-philipsjs==3.1.1 habitipy==0.2.0 # homeassistant.components.bluetooth -habluetooth==2.7.0 +habluetooth==2.8.0 # homeassistant.components.cloud hass-nabucasa==0.78.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index b7a4a59a18e..aeb38c28aa1 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -843,7 +843,7 @@ ha-philipsjs==3.1.1 habitipy==0.2.0 # homeassistant.components.bluetooth -habluetooth==2.7.0 +habluetooth==2.8.0 # homeassistant.components.cloud hass-nabucasa==0.78.0