Simplify the homekit_controller unignore journey (#66353)

pull/66375/head
Jc2k 2022-02-12 13:16:05 +00:00 committed by GitHub
parent 5e5659d758
commit 95e4ea8fcd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 31 deletions

View File

@ -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."""

View File

@ -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"],

View File

@ -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

View File

@ -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

View File

@ -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):