From c14d9ab9576a4de1a43a22568f69ea9ffea2e0c5 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Sun, 2 Oct 2022 19:10:41 +0200 Subject: [PATCH] Link discovered homekit devices to domain (#13950) --- .../integrations/dialog-add-integration.ts | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/panels/config/integrations/dialog-add-integration.ts b/src/panels/config/integrations/dialog-add-integration.ts index f023eee2ae..34aea54d2b 100644 --- a/src/panels/config/integrations/dialog-add-integration.ts +++ b/src/panels/config/integrations/dialog-add-integration.ts @@ -509,7 +509,16 @@ class AddIntegrationDialog extends LitElement { if (integration.integrations) { const integrations = this._integrations![integration.domain].integrations!; - this._fetchFlowsInProgress(Object.keys(integrations)); + let domains = Object.keys(integrations); + if (integration.iot_standards?.includes("homekit")) { + // if homekit is supported, also fetch the discovered homekit devices + domains.push("homekit_controller"); + } + if (integration.domain === "apple") { + // we show discoverd homekit devices in their own brand section, dont show them at apple + domains = domains.filter((domain) => domain !== "homekit_controller"); + } + this._fetchFlowsInProgress(domains); this._pickedBrand = integration.domain; return; } @@ -603,7 +612,14 @@ class AddIntegrationDialog extends LitElement { private async _fetchFlowsInProgress(domains: string[]) { const flowsInProgress = ( await fetchConfigFlowInProgress(this.hass.connection) - ).filter((flow) => domains.includes(flow.handler)); + ).filter( + (flow) => + // filter config flows that are not for the integration we are looking for + domains.includes(flow.handler) || + // filter config flows of other domains (like homekit) that are for the domains we are looking for + ("alternative_domain" in flow.context && + domains.includes(flow.context.alternative_domain)) + ); if (flowsInProgress.length) { this._flowsInProgress = flowsInProgress;