From 1fe44265f025b0411a68e145d094fefac222e8e3 Mon Sep 17 00:00:00 2001 From: Dave T <17680170+davet2001@users.noreply.github.com> Date: Mon, 6 Jan 2025 22:32:39 +0000 Subject: [PATCH] Add max branches configuration from GUI --- src/hui-power-flow-card.ts | 3 +++ src/power-flow-card-editor.ts | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/hui-power-flow-card.ts b/src/hui-power-flow-card.ts index 58a5643..712785a 100644 --- a/src/hui-power-flow-card.ts +++ b/src/hui-power-flow-card.ts @@ -219,6 +219,8 @@ class HuiPowerFlowCard extends LitElement implements LovelaceCard { delete (config.generation_entity) } + const maxConsumerBranches = this._config.max_consumer_branches || 0; + let gridInRoute: ElecRoute | null = null; if (config.power_from_grid_entity) { const stateObj = this.hass.states[config.power_from_grid_entity]; @@ -322,6 +324,7 @@ class HuiPowerFlowCard extends LitElement implements LovelaceCard { .gridOutRoute=${gridOutRoute || undefined} .generationInRoutes=${generationInRoutes} .consumerRoutes=${consumerRoutes} + .maxConsumerBranches=${maxConsumerBranches} > diff --git a/src/power-flow-card-editor.ts b/src/power-flow-card-editor.ts index 37a3c4a..b9345a8 100644 --- a/src/power-flow-card-editor.ts +++ b/src/power-flow-card-editor.ts @@ -36,6 +36,16 @@ const schema = [ } } }, + { + name: "max_consumer_branches", + selector: { + number: { + min: 0, + max: 10, + mode: "slider", + } + } + } // { name: "group_small", selector: { boolean: {} } }, ]; @@ -61,6 +71,7 @@ export class PowerFlowCardEditor extends LitElement implements LovelaceCardEdito case "power_from_grid_entity": return "Power from grid"; case "group_small": return "Group low values together"; case "generation_entity": return "Power from generation (optional)"; + case "max_consumer_branches": return "Limit displayed consumer branches (0 for unlimited)"; } console.error("Error name key missing for '" + schema.name + "'") return "" @@ -145,6 +156,11 @@ export class PowerFlowCardEditor extends LitElement implements LovelaceCardEdito configValue = "generation_entity"; value = value.generation_entity; } + else if (value.max_consumer_branches + !== this._config.max_consumer_branches || -1) { + configValue = "max_consumer_branches"; + value = value.max_consumer_branches; + } else { console.warn("unhandled change in "); }