From f01a8e2d774c31da2a0b292292719ea080480e03 Mon Sep 17 00:00:00 2001 From: Ludeeus Date: Sat, 5 Sep 2020 20:40:37 +0000 Subject: [PATCH 1/6] Display services as services and not devices --- .../integrations/ha-integration-card.ts | 37 +++++++++++++++++-- src/translations/en.json | 1 + 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/panels/config/integrations/ha-integration-card.ts b/src/panels/config/integrations/ha-integration-card.ts index dddeaf67542f..3fe5f4472794 100644 --- a/src/panels/config/integrations/ha-integration-card.ts +++ b/src/panels/config/integrations/ha-integration-card.ts @@ -137,6 +137,7 @@ export class HaIntegrationCard extends LitElement { private _renderSingleEntry(item: ConfigEntryExtended): TemplateResult { const devices = this._getDevices(item); + const services = this._getServices(item); const entities = this._getEntities(item); return html` @@ -168,7 +169,7 @@ export class HaIntegrationCard extends LitElement {

${item.localized_domain_name === item.title ? "" : item.title}

- ${devices.length || entities.length + ${devices.length || services.length || entities.length ? html`
${devices.length @@ -183,7 +184,22 @@ export class HaIntegrationCard extends LitElement { > ` : ""} - ${devices.length && entities.length + ${devices.length && services.length + ? this.hass.localize("ui.common.and") + : ""} + ${services.length + ? html` + ${this.hass.localize( + "ui.panel.config.integrations.config_entry.services", + "count", + services.length + )} + ` + : ""} + ${(devices.length || services.length) && entities.length ? this.hass.localize("ui.common.and") : ""} ${entities.length @@ -304,8 +320,21 @@ export class HaIntegrationCard extends LitElement { if (!this.deviceRegistryEntries) { return []; } - return this.deviceRegistryEntries.filter((device) => - device.config_entries.includes(configEntry.entry_id) + return this.deviceRegistryEntries.filter( + (device) => + device.config_entries.includes(configEntry.entry_id) && + device.entry_type !== "service" + ); + } + + private _getServices(configEntry: ConfigEntry): DeviceRegistryEntry[] { + if (!this.deviceRegistryEntries) { + return []; + } + return this.deviceRegistryEntries.filter( + (device) => + device.config_entries.includes(configEntry.entry_id) && + device.entry_type === "service" ); } diff --git a/src/translations/en.json b/src/translations/en.json index 9977bae2471f..8e4ced534442 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -1638,6 +1638,7 @@ "config_entry": { "devices": "{count} {count, plural,\n one {device}\n other {devices}\n}", "entities": "{count} {count, plural,\n one {entity}\n other {entities}\n}", + "services": "{count} {count, plural,\n one {service}\n other {services}\n}", "rename": "Rename", "options": "Options", "system_options": "System options", From a114d719661328fd13e3136d863ff9a8829be5bf Mon Sep 17 00:00:00 2001 From: Ludeeus Date: Sat, 5 Sep 2020 20:55:55 +0000 Subject: [PATCH 2/6] remove seperator --- src/panels/config/integrations/ha-integration-card.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/panels/config/integrations/ha-integration-card.ts b/src/panels/config/integrations/ha-integration-card.ts index 3fe5f4472794..a382d09f74a8 100644 --- a/src/panels/config/integrations/ha-integration-card.ts +++ b/src/panels/config/integrations/ha-integration-card.ts @@ -184,9 +184,6 @@ export class HaIntegrationCard extends LitElement { > ` : ""} - ${devices.length && services.length - ? this.hass.localize("ui.common.and") - : ""} ${services.length ? html` Date: Sat, 5 Sep 2020 21:21:21 +0000 Subject: [PATCH 3/6] Add comma --- src/panels/config/integrations/ha-integration-card.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/panels/config/integrations/ha-integration-card.ts b/src/panels/config/integrations/ha-integration-card.ts index a382d09f74a8..7d188413d549 100644 --- a/src/panels/config/integrations/ha-integration-card.ts +++ b/src/panels/config/integrations/ha-integration-card.ts @@ -184,6 +184,7 @@ export class HaIntegrationCard extends LitElement { > ` : ""} + ${devices.length || services.length ? "," : ""} ${services.length ? html` Date: Sat, 5 Sep 2020 23:27:20 +0200 Subject: [PATCH 4/6] Update src/panels/config/integrations/ha-integration-card.ts Co-authored-by: Bram Kragten --- src/panels/config/integrations/ha-integration-card.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/panels/config/integrations/ha-integration-card.ts b/src/panels/config/integrations/ha-integration-card.ts index 7d188413d549..f2f88aaa6d7e 100644 --- a/src/panels/config/integrations/ha-integration-card.ts +++ b/src/panels/config/integrations/ha-integration-card.ts @@ -184,7 +184,7 @@ export class HaIntegrationCard extends LitElement { > ` : ""} - ${devices.length || services.length ? "," : ""} + ${devices.length && services.length ? "," : ""} ${services.length ? html` Date: Sat, 5 Sep 2020 21:40:21 +0000 Subject: [PATCH 5/6] Fix spacing --- src/panels/config/integrations/ha-integration-card.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/panels/config/integrations/ha-integration-card.ts b/src/panels/config/integrations/ha-integration-card.ts index f2f88aaa6d7e..19d9147dc056 100644 --- a/src/panels/config/integrations/ha-integration-card.ts +++ b/src/panels/config/integrations/ha-integration-card.ts @@ -181,10 +181,9 @@ export class HaIntegrationCard extends LitElement { "count", devices.length )} + >${devices.length && services.length ? "," : ""} ` : ""} - ${devices.length && services.length ? "," : ""} ${services.length ? html` Date: Sat, 5 Sep 2020 21:40:42 +0000 Subject: [PATCH 6/6] Remove check --- src/panels/config/integrations/ha-integration-card.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/panels/config/integrations/ha-integration-card.ts b/src/panels/config/integrations/ha-integration-card.ts index 19d9147dc056..a1625c7c2c43 100644 --- a/src/panels/config/integrations/ha-integration-card.ts +++ b/src/panels/config/integrations/ha-integration-card.ts @@ -181,7 +181,7 @@ export class HaIntegrationCard extends LitElement { "count", devices.length )}${devices.length && services.length ? "," : ""} + >${services.length ? "," : ""} ` : ""} ${services.length