Link discovered homekit devices to domain (#13950)

This commit is contained in:
Bram Kragten 2022-10-02 19:10:41 +02:00 committed by GitHub
parent dd695545d3
commit c14d9ab957
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -509,7 +509,16 @@ class AddIntegrationDialog extends LitElement {
if (integration.integrations) { if (integration.integrations) {
const integrations = const integrations =
this._integrations![integration.domain].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; this._pickedBrand = integration.domain;
return; return;
} }
@ -603,7 +612,14 @@ class AddIntegrationDialog extends LitElement {
private async _fetchFlowsInProgress(domains: string[]) { private async _fetchFlowsInProgress(domains: string[]) {
const flowsInProgress = ( const flowsInProgress = (
await fetchConfigFlowInProgress(this.hass.connection) 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) { if (flowsInProgress.length) {
this._flowsInProgress = flowsInProgress; this._flowsInProgress = flowsInProgress;