diff --git a/src/data/energy.ts b/src/data/energy.ts index 2ec9df45e3..c0aac9ed0b 100644 --- a/src/data/energy.ts +++ b/src/data/energy.ts @@ -273,14 +273,15 @@ export interface EnergyData { export const getReferencedStatisticIds = ( prefs: EnergyPreferences, info: EnergyInfo, - exclude?: string[] + includeTypes?: string[] ): string[] => { const statIDs: string[] = []; for (const source of prefs.energy_sources) { - if (exclude?.includes(source.type)) { + if (includeTypes && !includeTypes.includes(source.type)) { continue; } + if (source.type === "solar") { statIDs.push(source.stat_energy_from); continue; @@ -288,6 +289,7 @@ export const getReferencedStatisticIds = ( if (source.type === "gas" || source.type === "water") { statIDs.push(source.stat_energy_from); + if (source.stat_cost) { statIDs.push(source.stat_cost); } @@ -366,7 +368,6 @@ const getEnergyData = async ( } } - const waterStatIds: string[] = []; const consumptionStatIDs: string[] = []; for (const source of prefs.energy_sources) { // grid source @@ -375,11 +376,14 @@ const getEnergyData = async ( consumptionStatIDs.push(flowFrom.stat_energy_from); } } - if (source.type === "water") { - waterStatIds.push(source.stat_energy_from); - } } - const energyStatIds = getReferencedStatisticIds(prefs, info, ["water"]); + const energyStatIds = getReferencedStatisticIds(prefs, info, [ + "grid", + "solar", + "battery", + "gas", + ]); + const waterStatIds = getReferencedStatisticIds(prefs, info, ["water"]); const allStatIDs = [...energyStatIds, ...waterStatIds];