From 3229ae237ebb81846945c42ae7c96db6612f7597 Mon Sep 17 00:00:00 2001 From: Gunnar Skjold Date: Wed, 20 Sep 2023 20:29:54 +0200 Subject: [PATCH] Fix for tariff peak overwrite --- lib/EnergyAccounting/src/EnergyAccounting.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/EnergyAccounting/src/EnergyAccounting.cpp b/lib/EnergyAccounting/src/EnergyAccounting.cpp index 9f4441eb..593a734f 100644 --- a/lib/EnergyAccounting/src/EnergyAccounting.cpp +++ b/lib/EnergyAccounting/src/EnergyAccounting.cpp @@ -542,11 +542,11 @@ bool EnergyAccounting::updateMax(uint16_t val, uint8_t day) { return false; } } - uint16_t test = 0; + uint16_t test = val; uint8_t idx = 255; for(uint8_t i = 0; i < 5; i++) { if(val > data.peaks[i].value) { - if(test < data.peaks[i].value) { + if(test > data.peaks[i].value) { test = data.peaks[i].value; idx = i; }