master
Michael Zanetti 2021-11-23 00:47:11 +01:00
parent 034f90d7a9
commit a34dd7642b
3 changed files with 6 additions and 4 deletions

View File

@ -102,7 +102,7 @@ Q_DECLARE_METATYPE(PowerBalanceLogEntries)
class ThingPowerLogEntry {
Q_GADGET
Q_PROPERTY(QDateTime timstamp READ timestamp)
Q_PROPERTY(QDateTime timestamp READ timestamp)
Q_PROPERTY(QUuid thingId READ thingId)
Q_PROPERTY(double currentPower READ currentPower)
Q_PROPERTY(double totalConsumption READ totalConsumption)

View File

@ -139,6 +139,8 @@ ThingPowerLogEntries EnergyLogger::thingPowerLogs(SampleRate sampleRate, const Q
QVariantList bindValues;
bindValues << sampleRate;
qCDebug(dcEnergyExperience()) << "Fetching thing power logs for" << thingIds;
QStringList thingsQuery;
foreach (const ThingId &thingId, thingIds) {
thingsQuery.append("thingId = ?");
@ -598,7 +600,7 @@ bool EnergyLogger::insertPowerBalance(const QDateTime &timestamp, SampleRate sam
query.addBindValue(totalReturn);
query.exec();
if (query.lastError().isValid()) {
qCWarning(dcEnergyExperience()) << "Error logging consumption sample:" << query.lastError();
qCWarning(dcEnergyExperience()) << "Error logging consumption sample:" << query.lastError() << query.executedQuery();
return false;
}
emit powerBalanceEntryAdded(sampleRate, PowerBalanceLogEntry(timestamp, consumption, production, acquisition, storage, totalConsumption, totalProduction, totalAcquisition, totalReturn));