Smaller fixes and cleanups in the energy view
This commit is contained in:
parent
6d049101f4
commit
f161e23e0b
@ -68,7 +68,7 @@ MainViewBase {
|
|||||||
engine: _engine
|
engine: _engine
|
||||||
shownInterfaces: ["energymeter"]
|
shownInterfaces: ["energymeter"]
|
||||||
}
|
}
|
||||||
readonly property Thing rootMeter: energyMeters.count > 0 ? energyMeters.get(0) : null
|
readonly property Thing rootMeter: engine.thingManager.fetchingData ? null : engine.thingManager.things.getThing(energyManager.rootMeterId)
|
||||||
|
|
||||||
ThingsProxy {
|
ThingsProxy {
|
||||||
id: consumers
|
id: consumers
|
||||||
@ -167,6 +167,7 @@ MainViewBase {
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredHeight: width
|
Layout.preferredHeight: width
|
||||||
energyManager: energyManager
|
energyManager: energyManager
|
||||||
|
visible: rootMeter != null
|
||||||
}
|
}
|
||||||
|
|
||||||
ConsumerStats {
|
ConsumerStats {
|
||||||
@ -200,7 +201,7 @@ MainViewBase {
|
|||||||
EmptyViewPlaceholder {
|
EmptyViewPlaceholder {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
width: parent.width - app.margins * 2
|
width: parent.width - app.margins * 2
|
||||||
visible: engine.jsonRpcClient.experiences.hasOwnProperty("Energy") && !engine.thingManager.fetchingData && energyMeters.count == 0
|
visible: engine.jsonRpcClient.experiences.hasOwnProperty("Energy") && !engine.thingManager.fetchingData && energyMeters.count == 0 && consumers.count == 0
|
||||||
title: qsTr("There are no energy meters installed.")
|
title: qsTr("There are no energy meters installed.")
|
||||||
text: qsTr("To get an overview of your current energy usage, install an energy meter.")
|
text: qsTr("To get an overview of your current energy usage, install an energy meter.")
|
||||||
imageSource: "../images/smartmeter.svg"
|
imageSource: "../images/smartmeter.svg"
|
||||||
|
|||||||
@ -47,6 +47,8 @@ ChartView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: updateConsumers()
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
id: d
|
id: d
|
||||||
property var thingsColorMap: ({})
|
property var thingsColorMap: ({})
|
||||||
@ -56,6 +58,10 @@ ChartView {
|
|||||||
function updateConsumers() {
|
function updateConsumers() {
|
||||||
consumersBalanceSeries.clear();
|
consumersBalanceSeries.clear();
|
||||||
|
|
||||||
|
if (engine.thingManager.fetchingData) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var unknownConsumption = energyManager.currentPowerConsumption
|
var unknownConsumption = energyManager.currentPowerConsumption
|
||||||
|
|
||||||
var colorMap = {}
|
var colorMap = {}
|
||||||
@ -110,7 +116,6 @@ ChartView {
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
font: Style.bigFont
|
font: Style.bigFont
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,8 +134,13 @@ ChartView {
|
|||||||
sortOrder: Qt.DescendingOrder
|
sortOrder: Qt.DescendingOrder
|
||||||
}
|
}
|
||||||
delegate: ColumnLayout {
|
delegate: ColumnLayout {
|
||||||
|
id: consumerDelegate
|
||||||
width: parent.width
|
width: parent.width
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
property Thing consumer: consumers.getThing(model.id)
|
||||||
|
property State currentPowerState: consumer ? consumer.stateByName("currentPower") : null
|
||||||
|
property double value: currentPowerState ? currentPowerState.value : 0
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
text: model.name
|
text: model.name
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
@ -138,14 +148,11 @@ ChartView {
|
|||||||
font: Style.extraSmallFont
|
font: Style.extraSmallFont
|
||||||
}
|
}
|
||||||
Label {
|
Label {
|
||||||
property Thing consumer: sortedConsumers.get(index)
|
|
||||||
property State currentPowerState: consumer ? consumer.stateByName("currentPower") : null
|
|
||||||
property double value: currentPowerState ? currentPowerState.value : 0
|
|
||||||
|
|
||||||
color: d.thingsColorMap[consumer]
|
color: d.thingsColorMap[consumer]
|
||||||
text: "%1 %2"
|
text: "%1 %2"
|
||||||
.arg((value / (value > 1000 ? 1000 : 1)).toFixed(1))
|
.arg((consumerDelegate.value / (consumerDelegate.value > 1000 ? 1000 : 1)).toFixed(1))
|
||||||
.arg(value > 1000 ? "kWh" : "W")
|
.arg(consumerDelegate.value > 1000 ? "kWh" : "W")
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
font: Style.smallFont
|
font: Style.smallFont
|
||||||
|
|||||||
@ -47,6 +47,10 @@ StatsBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
onCurrentValueChanged: {
|
onCurrentValueChanged: {
|
||||||
|
if (currentValue === undefined) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
var config = root.configs[currentValue.config]
|
var config = root.configs[currentValue.config]
|
||||||
print("config:", config.startTime(), config.sampleRate)
|
print("config:", config.startTime(), config.sampleRate)
|
||||||
|
|
||||||
@ -353,9 +357,6 @@ StatsBase {
|
|||||||
top: parent.top
|
top: parent.top
|
||||||
margins: Style.smallMargins
|
margins: Style.smallMargins
|
||||||
}
|
}
|
||||||
// Label {
|
|
||||||
// text: powerBalanceLogs.count + ":" + categoryAxis.count + ":" + toolTip.idx
|
|
||||||
// }
|
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
text: categoryAxis.timestamps.length > toolTip.idx ? root.configs[selectionTabs.currentValue.config].toLongLabel(categoryAxis.timestamps[toolTip.idx]) : ""
|
text: categoryAxis.timestamps.length > toolTip.idx ? root.configs[selectionTabs.currentValue.config].toLongLabel(categoryAxis.timestamps[toolTip.idx]) : ""
|
||||||
|
|||||||
Reference in New Issue
Block a user