From 21f3eb91033e7ddcdf886ccc8d7eae8e3037194b Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Mon, 16 Jan 2023 07:10:36 +0100 Subject: [PATCH] filter disabled hardware integrations (#14964) --- .../config/hardware/ha-config-hardware.ts | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/panels/config/hardware/ha-config-hardware.ts b/src/panels/config/hardware/ha-config-hardware.ts index c3a0524735..40b181441e 100644 --- a/src/panels/config/hardware/ha-config-hardware.ts +++ b/src/panels/config/hardware/ha-config-hardware.ts @@ -39,6 +39,7 @@ import { rebootHost, shutdownHost, } from "../../../data/hassio/host"; +import { scanUSBDevices } from "../../../data/usb"; import { showOptionsFlowDialog } from "../../../dialogs/config-flow/show-dialog-options-flow"; import { showAlertDialog, @@ -219,6 +220,10 @@ class HaConfigHardware extends SubscribeMixin(LitElement) { } protected render(): TemplateResult { + if (!this._configEntries) { + return html``; + } + let boardId: string | undefined; let boardName: string | undefined; let imageURL: string | undefined; @@ -230,13 +235,22 @@ class HaConfigHardware extends SubscribeMixin(LitElement) { ); const dongles = this._hardwareInfo?.hardware.filter( - (hw) => hw.dongle !== null + (hw) => + hw.dongle !== null && + (!hw.config_entries.length || + hw.config_entries.some( + (entryId) => + this._configEntries![entryId] && + !this._configEntries![entryId].disabled_by + )) ); if (boardData) { boardConfigEntries = boardData.config_entries - .map((id) => this._configEntries?.[id]) - .filter((entry) => entry?.supports_options) as ConfigEntry[]; + .map((id) => this._configEntries![id]) + .filter( + (entry) => entry?.supports_options && !entry.disabled_by + ) as ConfigEntry[]; boardId = boardData.board!.hassio_board_id; boardName = boardData.name; documentationURL = boardData.url; @@ -362,8 +376,10 @@ class HaConfigHardware extends SubscribeMixin(LitElement) { ? html` ${dongles.map((dongle) => { const configEntry = dongle.config_entries - .map((id) => this._configEntries?.[id]) - .filter((entry) => entry?.supports_options)[0]; + .map((id) => this._configEntries![id]) + .filter( + (entry) => entry?.supports_options && !entry.disabled_by + )[0]; return html`
${dongle.name}${configEntry ? html`