Fix add integration discovery (#14432)

* Fix add integration discovery

* Update show-dialog-config-flow.ts

* Update src/panels/config/integrations/dialog-add-integration.ts

Co-authored-by: Joakim Sørensen <ludeeus@ludeeus.dev>

Co-authored-by: Joakim Sørensen <ludeeus@ludeeus.dev>
This commit is contained in:
Bram Kragten 2022-11-28 12:32:59 +01:00 committed by GitHub
parent 147b1f34ac
commit aa1e9cedca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 5 deletions

View File

@ -87,9 +87,11 @@ export const showConfigFlowDialog = (
}, },
renderShowFormStepFieldError(hass, step, error) { renderShowFormStepFieldError(hass, step, error) {
return hass.localize( return (
`component.${step.handler}.config.error.${error}`, hass.localize(
step.description_placeholders `component.${step.handler}.config.error.${error}`,
step.description_placeholders
) || error
); );
}, },

View File

@ -48,6 +48,7 @@ export interface IntegrationListItem {
config_flow?: boolean; config_flow?: boolean;
is_helper?: boolean; is_helper?: boolean;
integrations?: string[]; integrations?: string[];
domains?: string[];
iot_standards?: string[]; iot_standards?: string[];
supported_by?: string; supported_by?: string;
cloud?: boolean; cloud?: boolean;
@ -188,6 +189,9 @@ class AddIntegrationDialog extends LitElement {
([dom, val]) => val.name || domainToName(localize, dom) ([dom, val]) => val.name || domainToName(localize, dom)
) )
: undefined, : undefined,
domains: integration.integrations
? Object.keys(integration.integrations)
: undefined,
is_built_in: integration.is_built_in !== false, is_built_in: integration.is_built_in !== false,
}); });
} else if (filter && "integration_type" in integration) { } else if (filter && "integration_type" in integration) {
@ -494,7 +498,7 @@ class AddIntegrationDialog extends LitElement {
} }
if (integration.integrations) { if (integration.integrations) {
let domains = integration.integrations; let domains = integration.domains || [];
if (integration.domain === "apple") { if (integration.domain === "apple") {
// we show discoverd homekit devices in their own brand section, dont show them at apple // we show discoverd homekit devices in their own brand section, dont show them at apple
domains = domains.filter((domain) => domain !== "homekit_controller"); domains = domains.filter((domain) => domain !== "homekit_controller");

View File

@ -174,6 +174,15 @@ class HaDomainIntegrations extends LitElement {
? html`<mwc-list-item ? html`<mwc-list-item
.domain=${this.domain} .domain=${this.domain}
@request-selected=${this._integrationPicked} @request-selected=${this._integrationPicked}
.integration=${{
...this.integration,
domain: this.domain,
name:
this.integration.name ||
domainToName(this.hass.localize, this.domain),
is_built_in: this.integration.is_built_in !== false,
cloud: this.integration.iot_class?.startsWith("cloud_"),
}}
hasMeta hasMeta
> >
${this.hass.localize("ui.panel.config.integrations.new_flow", { ${this.hass.localize("ui.panel.config.integrations.new_flow", {
@ -241,7 +250,8 @@ class HaDomainIntegrations extends LitElement {
(!this.integration!.integrations || (!this.integration!.integrations ||
!(domain in this.integration!.integrations))))) || !(domain in this.integration!.integrations))))) ||
// config_flow being undefined means its false // config_flow being undefined means its false
!(this.integration as Brand)!.integrations?.[domain]?.config_flow (!("integration_type" in this.integration!) &&
!this.integration!.integrations?.[domain]?.config_flow)
) { ) {
const manifest = await fetchIntegrationManifest(this.hass, domain); const manifest = await fetchIntegrationManifest(this.hass, domain);
showYamlIntegrationDialog(this, { manifest }); showYamlIntegrationDialog(this, { manifest });