mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Simplify the homekit_controller unignore journey (#66353)
This commit is contained in:
parent
5e5659d758
commit
95e4ea8fcd
@ -154,34 +154,16 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
if self.controller is None:
|
if self.controller is None:
|
||||||
await self._async_setup_controller()
|
await self._async_setup_controller()
|
||||||
|
|
||||||
devices = await self.controller.discover_ip(max_seconds=5)
|
try:
|
||||||
for device in devices:
|
device = await self.controller.find_ip_by_device_id(unique_id)
|
||||||
if normalize_hkid(device.device_id) != unique_id:
|
except aiohomekit.AccessoryNotFoundError:
|
||||||
continue
|
return self.async_abort(reason="accessory_not_found_error")
|
||||||
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": "",
|
|
||||||
},
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
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):
|
async def _hkid_is_homekit(self, hkid):
|
||||||
"""Determine if the device is a homekit bridge or accessory."""
|
"""Determine if the device is a homekit bridge or accessory."""
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
"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==0.7.7"],
|
"requirements": ["aiohomekit==0.7.8"],
|
||||||
"zeroconf": ["_hap._tcp.local."],
|
"zeroconf": ["_hap._tcp.local."],
|
||||||
"after_dependencies": ["zeroconf"],
|
"after_dependencies": ["zeroconf"],
|
||||||
"codeowners": ["@Jc2k", "@bdraco"],
|
"codeowners": ["@Jc2k", "@bdraco"],
|
||||||
|
@ -184,7 +184,7 @@ aioguardian==2021.11.0
|
|||||||
aioharmony==0.2.9
|
aioharmony==0.2.9
|
||||||
|
|
||||||
# homeassistant.components.homekit_controller
|
# homeassistant.components.homekit_controller
|
||||||
aiohomekit==0.7.7
|
aiohomekit==0.7.8
|
||||||
|
|
||||||
# homeassistant.components.emulated_hue
|
# homeassistant.components.emulated_hue
|
||||||
# homeassistant.components.http
|
# homeassistant.components.http
|
||||||
|
@ -134,7 +134,7 @@ aioguardian==2021.11.0
|
|||||||
aioharmony==0.2.9
|
aioharmony==0.2.9
|
||||||
|
|
||||||
# homeassistant.components.homekit_controller
|
# homeassistant.components.homekit_controller
|
||||||
aiohomekit==0.7.7
|
aiohomekit==0.7.8
|
||||||
|
|
||||||
# homeassistant.components.emulated_hue
|
# homeassistant.components.emulated_hue
|
||||||
# homeassistant.components.http
|
# homeassistant.components.http
|
||||||
|
@ -844,7 +844,7 @@ async def test_unignore_ignores_missing_devices(hass, controller):
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "abort"
|
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):
|
async def test_discovery_dismiss_existing_flow_on_paired(hass, controller):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user