Merge PR #790: Fix consumers history double loading glitch

This commit is contained in:
Jenkins nymea 2022-03-21 15:04:53 +01:00
commit d1e5330524
14 changed files with 214 additions and 62 deletions

View File

@ -259,7 +259,7 @@ void EnergyLogs::fetchLogs()
if (!m_endTime.isNull()) {
params.insert("to", m_endTime.toSecsSinceEpoch());
}
qCDebug(dcEnergyLogs()) << "Fetching energy logs" << params;
qCDebug(dcEnergyLogs()) << this << "Fetching energy logs" << params;
m_engine->jsonRpcClient()->sendCommand("Energy.Get" + logsName(), params, this, "getLogsResponse");
}

View File

@ -5326,7 +5326,7 @@ Möchtest Du fortfahren?</translation>
</message>
<message>
<source>This will start a system update. Note that the update might take several minutes and your %1 might not be functioning properly or restart during this time.</source>
<translation>Diese Aktion wird ein System-Update starten. Dies kann mehrere Minuten dauern und Dein %1 System könnte in dieser Zeit gegebenenfalls nicht ordungsgemäß funktionieren.</translation>
<translation type="vanished">Diese Aktion wird ein System-Update starten. Dies kann mehrere Minuten dauern und Dein %1 System könnte in dieser Zeit gegebenenfalls nicht ordungsgemäß funktionieren.</translation>
</message>
<message>
<source>
@ -5512,15 +5512,31 @@ Möchtest Du fortfahren?</translation>
</message>
<message>
<source>Self production: %1 kW</source>
<translation>Eigenproduktion: %1 kW</translation>
<translation type="vanished">Eigenproduktion: %1 kW</translation>
</message>
<message>
<source>From battery: %1 kW</source>
<translation>Batterie: %1 kW</translation>
<translation type="vanished">Batterie: %1 kW</translation>
</message>
<message>
<source>From grid: %1 kW</source>
<translation>Netzbezug: %1 kW</translation>
<translation type="vanished">Netzbezug: %1 kW</translation>
</message>
<message>
<source>Total consumption: %1 %2</source>
<translation>Gesamtverbrauch: %1 %2</translation>
</message>
<message>
<source>Self production: %1 %2</source>
<translation>Eigenproduktion: %1 %2</translation>
</message>
<message>
<source>From battery: %1 %2</source>
<translation>Von Batterie: %1 %2</translation>
</message>
<message>
<source>From grid: %1 %2</source>
<translation>Netzbezug: %1 %2</translation>
</message>
</context>
<context>
@ -5543,15 +5559,31 @@ Möchtest Du fortfahren?</translation>
</message>
<message>
<source>To battery: %1 kW</source>
<translation>Batterie: %1 kW</translation>
<translation type="vanished">Batterie: %1 kW</translation>
</message>
<message>
<source>To grid: %1 kW</source>
<translation>Netzeinspeisung: %1 kW</translation>
<translation type="vanished">Netzeinspeisung: %1 kW</translation>
</message>
<message>
<source>Consumed: %1 kW</source>
<translation>Verbraucht: %1 kW</translation>
<translation type="vanished">Verbraucht: %1 kW</translation>
</message>
<message>
<source>Total production: %1 %2</source>
<translation>Gesamtproduktion: %1 %2</translation>
</message>
<message>
<source>Consumed: %1 %2</source>
<translation>Verbraucht: %1 %2</translation>
</message>
<message>
<source>To battery: %1 %2</source>
<translation>Batterieladung: %1 %2</translation>
</message>
<message>
<source>To grid: %1 %2</source>
<translation>Netzeinspeisung: %1 %2</translation>
</message>
</context>
<context>

View File

@ -5239,15 +5239,19 @@ Do you want to proceed?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Self production: %1 kW</source>
<source>Total consumption: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>From battery: %1 kW</source>
<source>Self production: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>From grid: %1 kW</source>
<source>From battery: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>From grid: %1 %2</source>
<translation type="unfinished"></translation>
</message>
</context>
@ -5270,15 +5274,19 @@ Do you want to proceed?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>To battery: %1 kW</source>
<source>Total production: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>To grid: %1 kW</source>
<source>Consumed: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Consumed: %1 kW</source>
<source>To battery: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>To grid: %1 %2</source>
<translation type="unfinished"></translation>
</message>
</context>

View File

@ -5239,15 +5239,19 @@ Do you want to proceed?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Self production: %1 kW</source>
<source>Total consumption: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>From battery: %1 kW</source>
<source>Self production: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>From grid: %1 kW</source>
<source>From battery: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>From grid: %1 %2</source>
<translation type="unfinished"></translation>
</message>
</context>
@ -5270,15 +5274,19 @@ Do you want to proceed?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>To battery: %1 kW</source>
<source>Total production: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>To grid: %1 kW</source>
<source>Consumed: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Consumed: %1 kW</source>
<source>To battery: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>To grid: %1 %2</source>
<translation type="unfinished"></translation>
</message>
</context>

View File

@ -5286,15 +5286,19 @@ Do you want to proceed?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Self production: %1 kW</source>
<source>Total consumption: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>From battery: %1 kW</source>
<source>Self production: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>From grid: %1 kW</source>
<source>From battery: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>From grid: %1 %2</source>
<translation type="unfinished"></translation>
</message>
</context>
@ -5317,15 +5321,19 @@ Do you want to proceed?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>To battery: %1 kW</source>
<source>Total production: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>To grid: %1 kW</source>
<source>Consumed: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Consumed: %1 kW</source>
<source>To battery: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>To grid: %1 %2</source>
<translation type="unfinished"></translation>
</message>
</context>

View File

@ -5397,15 +5397,19 @@ Do you want to proceed?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Self production: %1 kW</source>
<source>Total consumption: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>From battery: %1 kW</source>
<source>Self production: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>From grid: %1 kW</source>
<source>From battery: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>From grid: %1 %2</source>
<translation type="unfinished"></translation>
</message>
</context>
@ -5428,15 +5432,19 @@ Do you want to proceed?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>To battery: %1 kW</source>
<source>Total production: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>To grid: %1 kW</source>
<source>Consumed: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Consumed: %1 kW</source>
<source>To battery: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>To grid: %1 %2</source>
<translation type="unfinished"></translation>
</message>
</context>

View File

@ -5297,15 +5297,19 @@ Do you want to proceed?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Self production: %1 kW</source>
<source>Total consumption: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>From battery: %1 kW</source>
<source>Self production: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>From grid: %1 kW</source>
<source>From battery: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>From grid: %1 %2</source>
<translation type="unfinished"></translation>
</message>
</context>
@ -5328,15 +5332,19 @@ Do you want to proceed?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>To battery: %1 kW</source>
<source>Total production: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>To grid: %1 kW</source>
<source>Consumed: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Consumed: %1 kW</source>
<source>To battery: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>To grid: %1 %2</source>
<translation type="unfinished"></translation>
</message>
</context>

View File

@ -5435,15 +5435,19 @@ Do you want to proceed?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Self production: %1 kW</source>
<source>Total consumption: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>From battery: %1 kW</source>
<source>Self production: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>From grid: %1 kW</source>
<source>From battery: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>From grid: %1 %2</source>
<translation type="unfinished"></translation>
</message>
</context>
@ -5466,15 +5470,19 @@ Do you want to proceed?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>To battery: %1 kW</source>
<source>Total production: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>To grid: %1 kW</source>
<source>Consumed: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Consumed: %1 kW</source>
<source>To battery: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>To grid: %1 %2</source>
<translation type="unfinished"></translation>
</message>
</context>

View File

@ -5222,15 +5222,19 @@ Do you want to proceed?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Self production: %1 kW</source>
<source>Total consumption: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>From battery: %1 kW</source>
<source>Self production: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>From grid: %1 kW</source>
<source>From battery: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>From grid: %1 %2</source>
<translation type="unfinished"></translation>
</message>
</context>
@ -5253,15 +5257,19 @@ Do you want to proceed?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>To battery: %1 kW</source>
<source>Total production: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>To grid: %1 kW</source>
<source>Consumed: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Consumed: %1 kW</source>
<source>To battery: %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>To grid: %1 %2</source>
<translation type="unfinished"></translation>
</message>
</context>

View File

@ -28,7 +28,7 @@ StatsBase {
}
function update() {
if (engine.thingManager.fetchingData || engine.tagsManager.busy) {
if (engine.thingManager.fetchingData || engine.tagsManager.busy || selectionTabs.currentValue === undefined) {
return
}
powerLogs.loadingInhibited = true

View File

@ -28,6 +28,14 @@ Item {
thingIds: []
loadingInhibited: thingIds.length === 0
onModelReset: {
for (var i = 0; i < consumers.count; i++) {
var consumer = consumers.get(i);
var series = d.thingsSeriesMap[consumer.id];
series.upperSeries.clear()
}
}
onEntriesAdded: {
var thingValues = ({})
var timestamp = entries[0].timestamp
@ -128,7 +136,6 @@ Item {
series.borderWidth = 0;
series.borderColor = series.color
// print("Adding thingId series", thing.id, thing.name)
var map = d.thingsSeriesMap
map[thing.id] = series
d.thingsSeriesMap = map

View File

@ -155,8 +155,7 @@ ChartView {
font: Style.extraSmallFont
}
Label {
color: d.thingsColorMap[consumer]
color: d.thingsColorMap.hasOwnProperty(consumer) ? d.thingsColorMap[consumer] : "transparent"
text: "%1 %2"
.arg((consumerDelegate.value / (consumerDelegate.value > 1000 ? 1000 : 1)).toFixed(1))
.arg(consumerDelegate.value > 1000 ? "kWh" : "W")

View File

@ -296,6 +296,14 @@ Item {
font: Style.smallFont
}
Label {
property double value: acquisitionUpperSeries.at(toolTip.seriesIndex).y
property bool translate: value >= 1000
property double translatedValue: value / (translate ? 1000 : 1)
text: qsTr("Total consumption: %1 %2").arg(translatedValue.toFixed(2)).arg(translate ? "kW" : "W")
font: Style.extraSmallFont
}
RowLayout {
Rectangle {
width: Style.extraSmallFont.pixelSize
@ -304,7 +312,14 @@ Item {
}
Label {
text: qsTr("Self production: %1 kW").arg(selfProductionUpperSeries.at(toolTip.seriesIndex).y.toFixed(2))
// Workaround for Qt bug that lowerSeries is non-notifyable and throws warnings
Component.onCompleted: lowerSeries = selfProductionSeries.lowerSeries
property XYSeries lowerSeries: null
property double value: selfProductionUpperSeries.at(toolTip.seriesIndex).y - lowerSeries.at(toolTip.seriesIndex).y
property bool translate: value >= 1000
property double translatedValue: value / (translate ? 1000 : 1)
text: qsTr("Self production: %1 %2").arg(translatedValue.toFixed(2)).arg(translate ? "kW" : "W")
font: Style.extraSmallFont
}
}
@ -316,7 +331,14 @@ Item {
}
Label {
text: qsTr("From battery: %1 kW").arg(storageUpperSeries.at(toolTip.seriesIndex).y.toFixed(2))
// Workaround for Qt bug that lowerSeries is non-notifyable and throws warnings
Component.onCompleted: lowerSeries = storageSeries.lowerSeries
property XYSeries lowerSeries: null
property double value: storageUpperSeries.at(toolTip.seriesIndex).y - lowerSeries.at(toolTip.seriesIndex).y
property bool translate: value >= 1000
property double translatedValue: value / (translate ? 1000 : 1)
text: qsTr("From battery: %1 %2").arg(translatedValue.toFixed(2)).arg(translate ? "kW" : "W")
font: Style.extraSmallFont
}
}
@ -328,7 +350,14 @@ Item {
}
Label {
text: qsTr("From grid: %1 kW").arg(acquisitionUpperSeries.at(toolTip.seriesIndex).y.toFixed(2))
// Workaround for Qt bug that lowerSeries is non-notifyable and throws warnings
Component.onCompleted: lowerSeries = acquisitionSeries.lowerSeries
property XYSeries lowerSeries: null
property double value: acquisitionUpperSeries.at(toolTip.seriesIndex).y - lowerSeries.at(toolTip.seriesIndex).y
property bool translate: value >= 1000
property double translatedValue: value / (translate ? 1000 : 1)
text: qsTr("From grid: %1 %2").arg(translatedValue.toFixed(2)).arg(translate ? "kW" : "W")
font: Style.extraSmallFont
}
}

View File

@ -286,15 +286,30 @@ Item {
font: Style.smallFont
}
Label {
property double value: acquisitionUpperSeries.at(toolTip.seriesIndex).y
property bool translate: value >= 1000
property double translatedValue: value / (translate ? 1000 : 1)
text: qsTr("Total production: %1 %2").arg(translatedValue.toFixed(2)).arg(translate ? "kW" : "W")
font: Style.extraSmallFont
}
RowLayout {
Rectangle {
width: Style.extraSmallFont.pixelSize
height: width
color: Style.green
color: Style.red
}
Label {
text: qsTr("Consumed: %1 kW").arg(selfConsumptionUpperSeries.at(toolTip.seriesIndex).y.toFixed(2))
// Workaround for Qt bug that lowerSeries is non-notifyable and throws warnings
Component.onCompleted: lowerSeries = selfConsumptionSeries.lowerSeries
property XYSeries lowerSeries: null
property double value: selfConsumptionUpperSeries.at(toolTip.seriesIndex).y - lowerSeries.at(toolTip.seriesIndex).y
property bool translate: value >= 1000
property double translatedValue: value / (translate ? 1000 : 1)
text: qsTr("Consumed: %1 %2").arg(translatedValue.toFixed(2)).arg(translate ? "kW" : "W")
font: Style.extraSmallFont
}
}
@ -306,7 +321,14 @@ Item {
}
Label {
text: qsTr("To battery: %1 kW").arg(storageUpperSeries.at(toolTip.seriesIndex).y.toFixed(2))
// Workaround for Qt bug that lowerSeries is non-notifyable and throws warnings
Component.onCompleted: lowerSeries = storageSeries.lowerSeries
property XYSeries lowerSeries: null
property double value: storageUpperSeries.at(toolTip.seriesIndex).y - lowerSeries.at(toolTip.seriesIndex).y
property bool translate: value >= 1000
property double translatedValue: value / (translate ? 1000 : 1)
text: qsTr("To battery: %1 %2").arg(translatedValue.toFixed(2)).arg(translate ? "kW" : "W")
font: Style.extraSmallFont
}
}
@ -314,11 +336,18 @@ Item {
Rectangle {
width: Style.extraSmallFont.pixelSize
height: width
color: Style.red
color: Style.green
}
Label {
text: qsTr("To grid: %1 kW").arg(acquisitionUpperSeries.at(toolTip.seriesIndex).y.toFixed(2))
// Workaround for Qt bug that lowerSeries is non-notifyable and throws warnings
Component.onCompleted: lowerSeries = acquisitionSeries.lowerSeries
property XYSeries lowerSeries: null
property double value: acquisitionUpperSeries.at(toolTip.seriesIndex).y - lowerSeries.at(toolTip.seriesIndex).y
property bool translate: value >= 1000
property double translatedValue: value / (translate ? 1000 : 1)
text: qsTr("To grid: %1 %2").arg(translatedValue.toFixed(2)).arg(translate ? "kW" : "W")
font: Style.extraSmallFont
}
}