From 3590ad06727d103a04cb63ebe361611af1fc2e53 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 2 Nov 2022 18:18:51 +0100 Subject: [PATCH] Fix water costs --- src/data/energy.ts | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/data/energy.ts b/src/data/energy.ts index 2ec9df45e3..3c36de47c7 100644 --- a/src/data/energy.ts +++ b/src/data/energy.ts @@ -273,21 +273,23 @@ export interface EnergyData { export const getReferencedStatisticIds = ( prefs: EnergyPreferences, info: EnergyInfo, - exclude?: string[] + excludeEnergyStatTypes?: string[] ): string[] => { const statIDs: string[] = []; for (const source of prefs.energy_sources) { - if (exclude?.includes(source.type)) { - continue; - } if (source.type === "solar") { - statIDs.push(source.stat_energy_from); + if (!excludeEnergyStatTypes?.includes(source.type)) { + statIDs.push(source.stat_energy_from); + } continue; } if (source.type === "gas" || source.type === "water") { - statIDs.push(source.stat_energy_from); + if (!excludeEnergyStatTypes?.includes(source.type)) { + statIDs.push(source.stat_energy_from); + } + if (source.stat_cost) { statIDs.push(source.stat_cost); } @@ -299,14 +301,18 @@ export const getReferencedStatisticIds = ( } if (source.type === "battery") { - statIDs.push(source.stat_energy_from); - statIDs.push(source.stat_energy_to); + if (!excludeEnergyStatTypes?.includes(source.type)) { + statIDs.push(source.stat_energy_from); + statIDs.push(source.stat_energy_to); + } continue; } // grid source for (const flowFrom of source.flow_from) { - statIDs.push(flowFrom.stat_energy_from); + if (!excludeEnergyStatTypes?.includes(source.type)) { + statIDs.push(flowFrom.stat_energy_from); + } if (flowFrom.stat_cost) { statIDs.push(flowFrom.stat_cost); } @@ -316,7 +322,9 @@ export const getReferencedStatisticIds = ( } } for (const flowTo of source.flow_to) { - statIDs.push(flowTo.stat_energy_to); + if (!excludeEnergyStatTypes?.includes(source.type)) { + statIDs.push(flowTo.stat_energy_to); + } if (flowTo.stat_compensation) { statIDs.push(flowTo.stat_compensation); }