1
0
mirror of https://github.com/home-assistant/frontend.git synced 2025-12-20 02:38:53 +00:00

Fix water sankey calculation to include total supply from sources (#28191)

This commit is contained in:
Petar Petrov
2025-11-27 17:44:56 +02:00
committed by GitHub
parent 9bc896241d
commit 92611f46f4

View File

@@ -98,17 +98,32 @@ class HuiWaterSankeyCard
const nodes: Node[] = []; const nodes: Node[] = [];
const links: Link[] = []; const links: Link[] = [];
// Calculate total water consumption from all devices // Calculate total water consumption from all sources or devices
let totalWaterConsumption = 0; const totalDownstreamConsumption = prefs.device_consumption_water.reduce(
prefs.device_consumption_water.forEach((device) => { (total, device) => {
const value =
device.stat_consumption in this._data!.stats
? calculateStatisticSumGrowth(
this._data!.stats[device.stat_consumption]
) || 0
: 0;
return total + value;
},
0
);
const totalSourceSupply = waterSources.reduce((total, source) => {
const value = const value =
device.stat_consumption in this._data!.stats source.stat_energy_from in this._data!.stats
? calculateStatisticSumGrowth( ? calculateStatisticSumGrowth(
this._data!.stats[device.stat_consumption] this._data!.stats[source.stat_energy_from]
) || 0 ) || 0
: 0; : 0;
totalWaterConsumption += value; return total + value;
}); }, 0);
const totalWaterConsumption = Math.max(
totalDownstreamConsumption,
totalSourceSupply
);
// Create home/consumption node // Create home/consumption node
const homeNode: Node = { const homeNode: Node = {