Fix energy logs sometimes resetting to 0 on reboots

master
Michael Zanetti 2022-05-06 17:20:07 +02:00
parent a30fffd294
commit 1387353074
2 changed files with 3 additions and 3 deletions

View File

@ -323,7 +323,7 @@ void EnergyLogger::sample()
medianAcquisition /= sampleStart.msecsTo(sampleEnd);
medianStorage /= sampleStart.msecsTo(sampleEnd);
PowerBalanceLogEntry newest = m_balanceLiveLog.count() > 0 ? m_balanceLiveLog.at(0) : PowerBalanceLogEntry();
PowerBalanceLogEntry newest = latestLogEntry(SampleRateAny);
double totalConsumption = newest.totalConsumption();
double totalProduction = newest.totalProduction();
double totalAcquisition = newest.totalAcquisition();
@ -349,7 +349,7 @@ void EnergyLogger::sample()
}
medianPower /= sampleStart.msecsTo(sampleEnd);
ThingPowerLogEntry newest = entries.count() > 0 ? entries.first() : ThingPowerLogEntry();
ThingPowerLogEntry newest = latestLogEntry(SampleRateAny, thingId);
double totalConsumption = newest.totalConsumption();
double totalProduction = newest.totalProduction();

View File

@ -64,7 +64,7 @@ EnergyManager::EnergyError EnergyManagerImpl::setRootMeter(const ThingId &rootMe
m_rootMeter = rootMeter;
QSettings settings(NymeaSettings::settingsPath() + "/energy.conf", QSettings::IniFormat);
settings.setValue("rootMeterThingId", rootMeter->id());
settings.setValue("rootMeterThingId", rootMeter->id().toString());
emit rootMeterChanged();
}