diff --git a/libnymea-energy/energylogs.h b/libnymea-energy/energylogs.h index 2881f2f..79c89a2 100644 --- a/libnymea-energy/energylogs.h +++ b/libnymea-energy/energylogs.h @@ -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) diff --git a/plugin/energyjsonhandler.cpp b/plugin/energyjsonhandler.cpp index 954e83b..052266e 100644 --- a/plugin/energyjsonhandler.cpp +++ b/plugin/energyjsonhandler.cpp @@ -188,6 +188,6 @@ JsonReply *EnergyJsonHandler::GetThingPowerLogs(const QVariantMap ¶ms) QDateTime from = params.contains("from") ? QDateTime::fromMSecsSinceEpoch(params.value("from").toLongLong() * 1000) : QDateTime(); QDateTime to = params.contains("to") ? QDateTime::fromMSecsSinceEpoch(params.value("to").toLongLong() * 1000) : QDateTime(); QVariantMap returns; - returns.insert("thingPowerLogEntries",pack(m_energyManager->logs()->thingPowerLogs(sampleRate, thingIds, from, to))); + returns.insert("thingPowerLogEntries", pack(m_energyManager->logs()->thingPowerLogs(sampleRate, thingIds, from, to))); return createReply(returns); } diff --git a/plugin/energylogger.cpp b/plugin/energylogger.cpp index 876ac8e..a223b8a 100644 --- a/plugin/energylogger.cpp +++ b/plugin/energylogger.cpp @@ -139,13 +139,15 @@ 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 = ?"); bindValues << thingId; } if (!thingsQuery.isEmpty()) { - queryString += "AND (" + thingsQuery.join(" OR ") + " )"; + queryString += " AND (" + thingsQuery.join(" OR ") + " )"; } if (!from.isNull()) { @@ -598,7 +600,7 @@ bool EnergyLogger::insertPowerBalance(const QDateTime ×tamp, 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));