From 6b8f85649f06072417a11090bd4617a46da0c998 Mon Sep 17 00:00:00 2001 From: Dave T <17680170+davet2001@users.noreply.github.com> Date: Sun, 5 Jan 2025 14:01:59 +0000 Subject: [PATCH] Fix issue where invalid power from grid entity would blank whole card --- src/hui-power-flow-card.ts | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/hui-power-flow-card.ts b/src/hui-power-flow-card.ts index 6419513..58a5643 100644 --- a/src/hui-power-flow-card.ts +++ b/src/hui-power-flow-card.ts @@ -55,18 +55,13 @@ class HuiPowerFlowCard extends LitElement implements LovelaceCard { if ( !config.power_from_grid_entity && !config.power_to_grid_entity && - !config.generation_entities && - !config.consumer_entities + !config.generation_entity && + config.consumer_entities.length === 0 ) { throw new Error("Must specify at least one entity"); } - if (config.power_from_grid_entity) { - if (!isValidEntityId(config.power_from_grid_entity)) { - throw new Error("Invalid power from grid entity specified"); - } - // @todo consider adding more config checks here. - this._config = { ...config }; - } + // @todo consider adding more config checks here. + this._config = { ...config }; } private static async getExtendedEntityRegistryEntries(_hass: HomeAssistant): Promise<{ [id: string]: ExtEntityRegistryEntry }> { @@ -267,7 +262,7 @@ class HuiPowerFlowCard extends LitElement implements LovelaceCard { } const generationInRoutes: { [id: string]: ElecRoute } = {}; - if (this._config.generation_entities) { + if (config.generation_entities) { for (const entity of config.generation_entities) { const stateObj = this.hass.states[entity]; if (!stateObj) {