diff --git a/homeassistant/components/homekit_controller/config_flow.py b/homeassistant/components/homekit_controller/config_flow.py index 3784e2830d7..82ab670f8db 100644 --- a/homeassistant/components/homekit_controller/config_flow.py +++ b/homeassistant/components/homekit_controller/config_flow.py @@ -154,34 +154,16 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): if self.controller is None: await self._async_setup_controller() - devices = await self.controller.discover_ip(max_seconds=5) - for device in devices: - if normalize_hkid(device.device_id) != unique_id: - continue - record = device.info - return await self.async_step_zeroconf( - zeroconf.ZeroconfServiceInfo( - host=record["address"], - addresses=[record["address"]], - port=record["port"], - hostname=record["name"], - type="_hap._tcp.local.", - name=record["name"], - properties={ - "md": record["md"], - "pv": record["pv"], - zeroconf.ATTR_PROPERTIES_ID: unique_id, - "c#": record["c#"], - "s#": record["s#"], - "ff": record["ff"], - "ci": record["ci"], - "sf": record["sf"], - "sh": "", - }, - ) - ) + try: + device = await self.controller.find_ip_by_device_id(unique_id) + except aiohomekit.AccessoryNotFoundError: + return self.async_abort(reason="accessory_not_found_error") - return self.async_abort(reason="no_devices") + self.name = device.info["name"].replace("._hap._tcp.local.", "") + self.model = device.info["md"] + self.hkid = normalize_hkid(device.info["id"]) + + return self._async_step_pair_show_form() async def _hkid_is_homekit(self, hkid): """Determine if the device is a homekit bridge or accessory.""" diff --git a/homeassistant/components/homekit_controller/manifest.json b/homeassistant/components/homekit_controller/manifest.json index ce7ae876e03..d156ae14256 100644 --- a/homeassistant/components/homekit_controller/manifest.json +++ b/homeassistant/components/homekit_controller/manifest.json @@ -3,7 +3,7 @@ "name": "HomeKit Controller", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/homekit_controller", - "requirements": ["aiohomekit==0.7.7"], + "requirements": ["aiohomekit==0.7.8"], "zeroconf": ["_hap._tcp.local."], "after_dependencies": ["zeroconf"], "codeowners": ["@Jc2k", "@bdraco"], diff --git a/requirements_all.txt b/requirements_all.txt index 394dd8099bc..b0c4267de7b 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -184,7 +184,7 @@ aioguardian==2021.11.0 aioharmony==0.2.9 # homeassistant.components.homekit_controller -aiohomekit==0.7.7 +aiohomekit==0.7.8 # homeassistant.components.emulated_hue # homeassistant.components.http diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 4f81c60171c..3fac8b4b859 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -134,7 +134,7 @@ aioguardian==2021.11.0 aioharmony==0.2.9 # homeassistant.components.homekit_controller -aiohomekit==0.7.7 +aiohomekit==0.7.8 # homeassistant.components.emulated_hue # homeassistant.components.http diff --git a/tests/components/homekit_controller/test_config_flow.py b/tests/components/homekit_controller/test_config_flow.py index 8a1f77d0e4c..101e4ebd024 100644 --- a/tests/components/homekit_controller/test_config_flow.py +++ b/tests/components/homekit_controller/test_config_flow.py @@ -844,7 +844,7 @@ async def test_unignore_ignores_missing_devices(hass, controller): ) assert result["type"] == "abort" - assert result["reason"] == "no_devices" + assert result["reason"] == "accessory_not_found_error" async def test_discovery_dismiss_existing_flow_on_paired(hass, controller):