From eee2c1e8fd11846d4932684aa6a687e6718688c1 Mon Sep 17 00:00:00 2001 From: Petar Petrov Date: Thu, 20 Nov 2025 19:45:04 +0200 Subject: [PATCH] Add power graphs in energy view (#28010) --- .../energy-electricity-view-strategy.ts | 27 +++++++++++++++++++ src/translations/en.json | 3 ++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/panels/energy/strategies/energy-electricity-view-strategy.ts b/src/panels/energy/strategies/energy-electricity-view-strategy.ts index 3e3139610c..382841df3b 100644 --- a/src/panels/energy/strategies/energy-electricity-view-strategy.ts +++ b/src/panels/energy/strategies/energy-electricity-view-strategy.ts @@ -46,12 +46,39 @@ export class EnergyElectricityViewStrategy extends ReactiveElement { const hasBattery = prefs.energy_sources.some( (source) => source.type === "battery" ); + const hasPowerSources = prefs.energy_sources.find( + (source) => + (source.type === "solar" && source.stat_rate) || + (source.type === "battery" && source.stat_rate) || + (source.type === "grid" && source.power?.length) + ); + const hasPowerDevices = prefs.device_consumption.find( + (device) => device.stat_rate + ); view.cards!.push({ type: "energy-compare", collection_key: "energy_dashboard", }); + if (hasPowerSources) { + if (hasPowerDevices) { + view.cards!.push({ + title: hass.localize("ui.panel.energy.cards.power_sankey_title"), + type: "power-sankey", + collection_key: collectionKey, + grid_options: { + columns: 24, + }, + }); + } + view.cards!.push({ + title: hass.localize("ui.panel.energy.cards.power_sources_graph_title"), + type: "power-sources-graph", + collection_key: collectionKey, + }); + } + // Only include if we have a grid or battery. if (hasGrid || hasBattery) { view.cards!.push({ diff --git a/src/translations/en.json b/src/translations/en.json index 9cf0b25b65..f467b57e5b 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -9470,7 +9470,8 @@ "energy_devices_detail_graph_title": "Individual devices detail usage", "energy_sankey_title": "Energy flow", "energy_top_consumers_title": "Top consumers", - "power_sankey_title": "Current power flow" + "power_sankey_title": "Current power flow", + "power_sources_graph_title": "Power sources" } }, "history": {