mirror of
https://github.com/home-assistant/core.git
synced 2025-11-15 22:10:09 +00:00
Exclude homekit accessories created by the homekit integration from homekit_controller (#48201)
This commit is contained in:
@@ -18,8 +18,6 @@ from .const import DOMAIN, KNOWN_DEVICES
|
||||
|
||||
HOMEKIT_DIR = ".homekit"
|
||||
HOMEKIT_BRIDGE_DOMAIN = "homekit"
|
||||
HOMEKIT_BRIDGE_SERIAL_NUMBER = "homekit.bridge"
|
||||
HOMEKIT_BRIDGE_MODEL = "Home Assistant HomeKit Bridge"
|
||||
|
||||
HOMEKIT_IGNORE = [
|
||||
# eufy Indoor Cam 2K and 2K Pan & Tilt
|
||||
@@ -181,8 +179,8 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow):
|
||||
|
||||
return self.async_abort(reason="no_devices")
|
||||
|
||||
async def _hkid_is_homekit_bridge(self, hkid):
|
||||
"""Determine if the device is a homekit bridge."""
|
||||
async def _hkid_is_homekit(self, hkid):
|
||||
"""Determine if the device is a homekit bridge or accessory."""
|
||||
dev_reg = await async_get_device_registry(self.hass)
|
||||
device = dev_reg.async_get_device(
|
||||
identifiers=set(), connections={(CONNECTION_NETWORK_MAC, hkid)}
|
||||
@@ -190,7 +188,13 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow):
|
||||
|
||||
if device is None:
|
||||
return False
|
||||
return device.model == HOMEKIT_BRIDGE_MODEL
|
||||
|
||||
for entry_id in device.config_entries:
|
||||
entry = self.hass.config_entries.async_get_entry(entry_id)
|
||||
if entry and entry.domain == HOMEKIT_BRIDGE_DOMAIN:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
async def async_step_zeroconf(self, discovery_info):
|
||||
"""Handle a discovered HomeKit accessory.
|
||||
@@ -266,8 +270,8 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow):
|
||||
if model in HOMEKIT_IGNORE:
|
||||
return self.async_abort(reason="ignored_model")
|
||||
|
||||
# If this is a HomeKit bridge exported by *this* HA instance ignore it.
|
||||
if await self._hkid_is_homekit_bridge(hkid):
|
||||
# If this is a HomeKit bridge/accessory exported by *this* HA instance ignore it.
|
||||
if await self._hkid_is_homekit(hkid):
|
||||
return self.async_abort(reason="ignored_model")
|
||||
|
||||
self.name = name
|
||||
|
||||
Reference in New Issue
Block a user