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