File tree Expand file tree Collapse file tree 1 file changed +22
-7
lines changed
src/panels/lovelace/cards/water Expand file tree Collapse file tree 1 file changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -98,17 +98,32 @@ class HuiWaterSankeyCard
9898 const nodes : Node [ ] = [ ] ;
9999 const links : Link [ ] = [ ] ;
100100
101- // Calculate total water consumption from all devices
102- let totalWaterConsumption = 0 ;
103- prefs . device_consumption_water . forEach ( ( device ) => {
101+ // Calculate total water consumption from all sources or devices
102+ const totalDownstreamConsumption = prefs . device_consumption_water . reduce (
103+ ( total , device ) => {
104+ const value =
105+ device . stat_consumption in this . _data ! . stats
106+ ? calculateStatisticSumGrowth (
107+ this . _data ! . stats [ device . stat_consumption ]
108+ ) || 0
109+ : 0 ;
110+ return total + value ;
111+ } ,
112+ 0
113+ ) ;
114+ const totalSourceSupply = waterSources . reduce ( ( total , source ) => {
104115 const value =
105- device . stat_consumption in this . _data ! . stats
116+ source . stat_energy_from in this . _data ! . stats
106117 ? calculateStatisticSumGrowth (
107- this . _data ! . stats [ device . stat_consumption ]
118+ this . _data ! . stats [ source . stat_energy_from ]
108119 ) || 0
109120 : 0 ;
110- totalWaterConsumption += value ;
111- } ) ;
121+ return total + value ;
122+ } , 0 ) ;
123+ const totalWaterConsumption = Math . max (
124+ totalDownstreamConsumption ,
125+ totalSourceSupply
126+ ) ;
112127
113128 // Create home/consumption node
114129 const homeNode : Node = {
You can’t perform that action at this time.
0 commit comments