Fix water costs (#14263)

This commit is contained in:
Bram Kragten 2022-11-02 18:59:00 +01:00 committed by GitHub
parent 79c8b7dc27
commit 3cd64675df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -273,14 +273,15 @@ export interface EnergyData {
export const getReferencedStatisticIds = ( export const getReferencedStatisticIds = (
prefs: EnergyPreferences, prefs: EnergyPreferences,
info: EnergyInfo, info: EnergyInfo,
exclude?: string[] includeTypes?: string[]
): string[] => { ): string[] => {
const statIDs: string[] = []; const statIDs: string[] = [];
for (const source of prefs.energy_sources) { for (const source of prefs.energy_sources) {
if (exclude?.includes(source.type)) { if (includeTypes && !includeTypes.includes(source.type)) {
continue; continue;
} }
if (source.type === "solar") { if (source.type === "solar") {
statIDs.push(source.stat_energy_from); statIDs.push(source.stat_energy_from);
continue; continue;
@ -288,6 +289,7 @@ export const getReferencedStatisticIds = (
if (source.type === "gas" || source.type === "water") { if (source.type === "gas" || source.type === "water") {
statIDs.push(source.stat_energy_from); statIDs.push(source.stat_energy_from);
if (source.stat_cost) { if (source.stat_cost) {
statIDs.push(source.stat_cost); statIDs.push(source.stat_cost);
} }
@ -366,7 +368,6 @@ const getEnergyData = async (
} }
} }
const waterStatIds: string[] = [];
const consumptionStatIDs: string[] = []; const consumptionStatIDs: string[] = [];
for (const source of prefs.energy_sources) { for (const source of prefs.energy_sources) {
// grid source // grid source
@ -375,11 +376,14 @@ const getEnergyData = async (
consumptionStatIDs.push(flowFrom.stat_energy_from); 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]; const allStatIDs = [...energyStatIds, ...waterStatIds];