Handle grouping by floor and area in power sankey card (#28162)

This commit is contained in:
Petar Petrov 2025-11-27 13:19:42 +02:00 committed by Bram Kragten
parent 39752f0e3f
commit 468139229c
2 changed files with 10 additions and 3 deletions

View File

@ -55,6 +55,9 @@ export class EnergyElectricityViewStrategy extends ReactiveElement {
const hasPowerDevices = prefs.device_consumption.find(
(device) => device.stat_rate
);
const showFloorsNAreas = !prefs.device_consumption.some(
(d) => d.included_in_stat
);
view.cards!.push({
type: "energy-compare",
@ -67,6 +70,8 @@ export class EnergyElectricityViewStrategy extends ReactiveElement {
title: hass.localize("ui.panel.energy.cards.power_sankey_title"),
type: "power-sankey",
collection_key: collectionKey,
group_by_floor: showFloorsNAreas,
group_by_area: showFloorsNAreas,
grid_options: {
columns: 24,
},
@ -156,9 +161,6 @@ export class EnergyElectricityViewStrategy extends ReactiveElement {
// Only include if we have at least 1 device in the config.
if (prefs.device_consumption.length) {
const showFloorsNAreas = !prefs.device_consumption.some(
(d) => d.included_in_stat
);
view.cards!.push({
title: hass.localize("ui.panel.energy.cards.energy_sankey_title"),
type: "energy-sankey",

View File

@ -81,10 +81,15 @@ export class EnergyViewStrategy extends ReactiveElement {
cards: [],
};
if (hasPowerSources && hasPowerDevices) {
const showFloorsNAreas = !prefs.device_consumption.some(
(d) => d.included_in_stat
);
overviewSection.cards!.push({
title: hass.localize("ui.panel.energy.cards.power_sankey_title"),
type: "power-sankey",
collection_key: collectionKey,
group_by_floor: showFloorsNAreas,
group_by_area: showFloorsNAreas,
grid_options: {
columns: 24,
},