diff --git a/plugin/energylogger.cpp b/plugin/energylogger.cpp index 7682042..0d254a4 100644 --- a/plugin/energylogger.cpp +++ b/plugin/energylogger.cpp @@ -325,7 +325,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(); @@ -351,7 +351,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(); diff --git a/plugin/energymanagerimpl.cpp b/plugin/energymanagerimpl.cpp index 7b20d00..1f3c1bc 100644 --- a/plugin/energymanagerimpl.cpp +++ b/plugin/energymanagerimpl.cpp @@ -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(); }