From f126da61e878e177b52afaa402248a4ff2a68ddc Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Sat, 25 Feb 2023 14:03:09 +0100 Subject: [PATCH] Don't show a positive currentPower for producers in thing page --- nymea-app/ui/devicepages/SmartMeterDevicePage.qml | 12 +++++++----- nymea-app/ui/mainviews/EnergyView.qml | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/nymea-app/ui/devicepages/SmartMeterDevicePage.qml b/nymea-app/ui/devicepages/SmartMeterDevicePage.qml index bed809c0..71c0eb3d 100644 --- a/nymea-app/ui/devicepages/SmartMeterDevicePage.qml +++ b/nymea-app/ui/devicepages/SmartMeterDevicePage.qml @@ -63,9 +63,11 @@ ThingPageBase { property bool isProduction: currentPowerState.value < 0 property bool isConsumption: currentPowerState.value > 0 - property double absValue: Math.abs(currentPowerState.value) - property double cleanVale: (absValue / (absValue > 1000 ? 1000 : 1)).toFixed(1) - property string unit: absValue > 1000 ? "kW" : "W" + property double normalizedValue: isProducer + ? Math.max(0, -currentPowerState.value) + : Math.abs(currentPowerState.value) + property double cleanValue: (normalizedValue / (normalizedValue > 1000 ? 1000 : 1)).toFixed(1) + property string unit: normalizedValue > 1000 ? "kW" : "W" readonly property bool isCharging: root.chargingState && root.chargingState.value === "charging" readonly property bool isDischarging: root.chargingState && root.chargingState.value === "discharging" @@ -159,7 +161,7 @@ ThingPageBase { Layout.fillWidth: true horizontalAlignment: Text.AlignHCenter font: Style.largeFont - text: "%1 %2".arg(root.cleanVale).arg(root.unit) + text: "%1 %2".arg(root.cleanValue).arg(root.unit) } Label { @@ -177,7 +179,7 @@ ThingPageBase { } } if (root.isProducer) { - return qsTr("Producing") + return root.currentPowerState.value < 0 ? qsTr("Producing") : qsTr("Idle") } if (root.isConsumer) { return qsTr("Consuming") diff --git a/nymea-app/ui/mainviews/EnergyView.qml b/nymea-app/ui/mainviews/EnergyView.qml index e5634a85..4cea42e4 100644 --- a/nymea-app/ui/mainviews/EnergyView.qml +++ b/nymea-app/ui/mainviews/EnergyView.qml @@ -118,7 +118,7 @@ MainViewBase { energyManager: energyManager visible: rootMeter != null || producers.count > 0 animationsEnabled: Qt.application.active && root.isCurrentItem && flickable.contentY < height - onAnimationsEnabledChanged: print("animations for power balance chart", animationsEnabled ? "enabled" : "disabled") +// onAnimationsEnabledChanged: print("animations for power balance chart", animationsEnabled ? "enabled" : "disabled") } PowerBalanceHistory {