From edaebcd85d0e62739b883d65eb2848072094dbae Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 23 Jul 2022 02:47:02 -0500 Subject: [PATCH] Pass in the bleak scanner instance to HKC (#75636) --- .../components/homekit_controller/manifest.json | 4 ++-- homeassistant/components/homekit_controller/utils.py | 9 +++++++-- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- tests/components/homekit_controller/conftest.py | 5 +++++ 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/homekit_controller/manifest.json b/homeassistant/components/homekit_controller/manifest.json index c784bad0d06..47472ba66bf 100644 --- a/homeassistant/components/homekit_controller/manifest.json +++ b/homeassistant/components/homekit_controller/manifest.json @@ -3,10 +3,10 @@ "name": "HomeKit Controller", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/homekit_controller", - "requirements": ["aiohomekit==1.1.9"], + "requirements": ["aiohomekit==1.1.10"], "zeroconf": ["_hap._tcp.local.", "_hap._udp.local."], "bluetooth": [{ "manufacturer_id": 76, "manufacturer_data_start": [6] }], - "after_dependencies": ["zeroconf"], + "dependencies": ["bluetooth", "zeroconf"], "codeowners": ["@Jc2k", "@bdraco"], "iot_class": "local_push", "loggers": ["aiohomekit", "commentjson"] diff --git a/homeassistant/components/homekit_controller/utils.py b/homeassistant/components/homekit_controller/utils.py index 892040d535f..d7780029331 100644 --- a/homeassistant/components/homekit_controller/utils.py +++ b/homeassistant/components/homekit_controller/utils.py @@ -3,7 +3,7 @@ from typing import cast from aiohomekit import Controller -from homeassistant.components import zeroconf +from homeassistant.components import bluetooth, zeroconf from homeassistant.const import EVENT_HOMEASSISTANT_STOP from homeassistant.core import Event, HomeAssistant @@ -28,7 +28,12 @@ async def async_get_controller(hass: HomeAssistant) -> Controller: if existing := hass.data.get(CONTROLLER): return cast(Controller, existing) - controller = Controller(async_zeroconf_instance=async_zeroconf_instance) + bleak_scanner_instance = bluetooth.async_get_scanner(hass) + + controller = Controller( + async_zeroconf_instance=async_zeroconf_instance, + bleak_scanner_instance=bleak_scanner_instance, + ) hass.data[CONTROLLER] = controller diff --git a/requirements_all.txt b/requirements_all.txt index 9451d3b8495..293eff63383 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -168,7 +168,7 @@ aioguardian==2022.07.0 aioharmony==0.2.9 # homeassistant.components.homekit_controller -aiohomekit==1.1.9 +aiohomekit==1.1.10 # homeassistant.components.emulated_hue # homeassistant.components.http diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 3faa25b829f..c4fb04b7cda 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -152,7 +152,7 @@ aioguardian==2022.07.0 aioharmony==0.2.9 # homeassistant.components.homekit_controller -aiohomekit==1.1.9 +aiohomekit==1.1.10 # homeassistant.components.emulated_hue # homeassistant.components.http diff --git a/tests/components/homekit_controller/conftest.py b/tests/components/homekit_controller/conftest.py index 81688f88a4b..043213ec159 100644 --- a/tests/components/homekit_controller/conftest.py +++ b/tests/components/homekit_controller/conftest.py @@ -37,3 +37,8 @@ def controller(hass): @pytest.fixture(autouse=True) def hk_mock_async_zeroconf(mock_async_zeroconf): """Auto mock zeroconf.""" + + +@pytest.fixture(autouse=True) +def auto_mock_bluetooth(mock_bluetooth): + """Auto mock bluetooth."""