Pass in the bleak scanner instance to HKC (#75636)

This commit is contained in:
J. Nick Koston 2022-07-23 02:47:02 -05:00 committed by GitHub
parent 8e86124470
commit edaebcd85d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 6 deletions

View File

@ -3,10 +3,10 @@
"name": "HomeKit Controller", "name": "HomeKit Controller",
"config_flow": true, "config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/homekit_controller", "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."], "zeroconf": ["_hap._tcp.local.", "_hap._udp.local."],
"bluetooth": [{ "manufacturer_id": 76, "manufacturer_data_start": [6] }], "bluetooth": [{ "manufacturer_id": 76, "manufacturer_data_start": [6] }],
"after_dependencies": ["zeroconf"], "dependencies": ["bluetooth", "zeroconf"],
"codeowners": ["@Jc2k", "@bdraco"], "codeowners": ["@Jc2k", "@bdraco"],
"iot_class": "local_push", "iot_class": "local_push",
"loggers": ["aiohomekit", "commentjson"] "loggers": ["aiohomekit", "commentjson"]

View File

@ -3,7 +3,7 @@ from typing import cast
from aiohomekit import Controller from aiohomekit import Controller
from homeassistant.components import zeroconf from homeassistant.components import bluetooth, zeroconf
from homeassistant.const import EVENT_HOMEASSISTANT_STOP from homeassistant.const import EVENT_HOMEASSISTANT_STOP
from homeassistant.core import Event, HomeAssistant from homeassistant.core import Event, HomeAssistant
@ -28,7 +28,12 @@ async def async_get_controller(hass: HomeAssistant) -> Controller:
if existing := hass.data.get(CONTROLLER): if existing := hass.data.get(CONTROLLER):
return cast(Controller, existing) 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 hass.data[CONTROLLER] = controller

View File

@ -168,7 +168,7 @@ aioguardian==2022.07.0
aioharmony==0.2.9 aioharmony==0.2.9
# homeassistant.components.homekit_controller # homeassistant.components.homekit_controller
aiohomekit==1.1.9 aiohomekit==1.1.10
# homeassistant.components.emulated_hue # homeassistant.components.emulated_hue
# homeassistant.components.http # homeassistant.components.http

View File

@ -152,7 +152,7 @@ aioguardian==2022.07.0
aioharmony==0.2.9 aioharmony==0.2.9
# homeassistant.components.homekit_controller # homeassistant.components.homekit_controller
aiohomekit==1.1.9 aiohomekit==1.1.10
# homeassistant.components.emulated_hue # homeassistant.components.emulated_hue
# homeassistant.components.http # homeassistant.components.http

View File

@ -37,3 +37,8 @@ def controller(hass):
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def hk_mock_async_zeroconf(mock_async_zeroconf): def hk_mock_async_zeroconf(mock_async_zeroconf):
"""Auto mock zeroconf.""" """Auto mock zeroconf."""
@pytest.fixture(autouse=True)
def auto_mock_bluetooth(mock_bluetooth):
"""Auto mock bluetooth."""