Changes after testing

This commit is contained in:
Gunnar Skjold
2023-05-05 18:12:26 +02:00
parent 90ebe3803d
commit 48eb640838
7 changed files with 40 additions and 17 deletions

View File

@@ -125,13 +125,15 @@ bool EnergyAccounting::update(AmsData* amsData) {
totalImport += ds->getDayImport(i);
totalExport += ds->getDayExport(i);
}
uint8_t accuracy;
uint8_t accuracy = 0;
uint64_t importUpdate = totalImport, exportUpdate = totalExport;
while(totalImport > UINT32_MAX || totalExport > UINT32_MAX) {
while(importUpdate > UINT32_MAX || exportUpdate > UINT32_MAX) {
accuracy++;
importUpdate = totalImport / pow(10, accuracy);
exportUpdate = totalExport / pow(10, accuracy);
}
data.lastMonthImport = importUpdate;
data.lastMonthExport = exportUpdate;
data.lastMonthAccuracy = accuracy;
data.month = local.Month;