diff --git a/libnymea-app-core/jsonrpc/jsonrpcclient.cpp b/libnymea-app-core/jsonrpc/jsonrpcclient.cpp index 69656d5d..eddce39f 100644 --- a/libnymea-app-core/jsonrpc/jsonrpcclient.cpp +++ b/libnymea-app-core/jsonrpc/jsonrpcclient.cpp @@ -303,7 +303,7 @@ void JsonRpcClient::sendRequest(const QVariantMap &request) { QVariantMap newRequest = request; newRequest.insert("token", m_token); -// qDebug() << "Sending request" << qUtf8Printable(QJsonDocument::fromVariant(newRequest).toJson()); + qDebug() << "Sending request" << qUtf8Printable(QJsonDocument::fromVariant(newRequest).toJson()); m_connection->sendData(QJsonDocument::fromVariant(newRequest).toJson(QJsonDocument::Compact) + "\n"); } @@ -340,7 +340,7 @@ void JsonRpcClient::dataReceived(const QByteArray &data) // qWarning() << "Could not parse json data from nymea" << m_receiveBuffer.left(splitIndex) << error.errorString(); return; } -// qDebug() << "received response" << qUtf8Printable(jsonDoc.toJson(QJsonDocument::Indented)); + qDebug() << "received response" << qUtf8Printable(jsonDoc.toJson(QJsonDocument::Indented)); m_receiveBuffer = m_receiveBuffer.right(m_receiveBuffer.length() - splitIndex - 1); if (!m_receiveBuffer.isEmpty()) { staticMetaObject.invokeMethod(this, "dataReceived", Qt::QueuedConnection, Q_ARG(QByteArray, QByteArray())); diff --git a/libnymea-app-core/models/logsmodelng.cpp b/libnymea-app-core/models/logsmodelng.cpp index 71b8bdc1..af341100 100644 --- a/libnymea-app-core/models/logsmodelng.cpp +++ b/libnymea-app-core/models/logsmodelng.cpp @@ -202,6 +202,8 @@ void LogsModelNg::logsReply(const QVariantMap &data) } if (newBlock.isEmpty()) { + m_busy = false; + emit busyChanged(); return; } @@ -248,10 +250,10 @@ void LogsModelNg::logsReply(const QVariantMap &data) // } if (m_graphSeries->count() == 0) { - qDebug() << "Adding 1st line series point:" << (offset + i) << QDateTime::currentDateTime().toMSecsSinceEpoch() << entry->value().toReal(); +// qDebug() << "Adding 1st line series point:" << (offset + i) << QDateTime::currentDateTime().toMSecsSinceEpoch() << entry->value().toReal(); m_graphSeries->append(QPointF(QDateTime::currentDateTime().toMSecsSinceEpoch(), entry->value().toReal())); } - qDebug() << "Adding line series point:" << (offset + i) << entry->timestamp().toMSecsSinceEpoch() << (entry->value().toReal()); +// qDebug() << "Adding line series point:" << (offset + i) << entry->timestamp().toMSecsSinceEpoch() << (entry->value().toReal()); m_graphSeries->append(QPointF(entry->timestamp().toMSecsSinceEpoch(), entry->value().toReal())); } } diff --git a/nymea-app/resources.qrc b/nymea-app/resources.qrc index 21499768..e3ef4ff8 100644 --- a/nymea-app/resources.qrc +++ b/nymea-app/resources.qrc @@ -135,5 +135,6 @@ ui/customviews/GenericTypeGraphPre110.qml ui/customviews/GenericTypeGraph.qml ui/devicepages/SmartMeterDevicePage.qml + ui/devicelistpages/SmartMeterDeviceListPage.qml diff --git a/nymea-app/ui/appsettings/AppSettingsPage.qml b/nymea-app/ui/appsettings/AppSettingsPage.qml index b2389bc8..9d26fb33 100644 --- a/nymea-app/ui/appsettings/AppSettingsPage.qml +++ b/nymea-app/ui/appsettings/AppSettingsPage.qml @@ -81,23 +81,6 @@ Page { } } - RowLayout { - Layout.fillWidth: true; Layout.leftMargin: app.margins; Layout.rightMargin: app.margins - Label { - Layout.fillWidth: true - text: qsTr("Graph style") - } - RadioButton { - checked: settings.graphStyle === "bars" - text: qsTr("Bars") - onClicked: settings.graphStyle = "bars" - } - RadioButton { - checked: settings.graphStyle === "bezier" - text: qsTr("Lines") - onClicked: settings.graphStyle = "bezier" - } - } CheckDelegate { Layout.fillWidth: true text: qsTr("Return to home on idle") diff --git a/nymea-app/ui/devicelistpages/SmartMeterDeviceListPage.qml b/nymea-app/ui/devicelistpages/SmartMeterDeviceListPage.qml new file mode 100644 index 00000000..eceb262f --- /dev/null +++ b/nymea-app/ui/devicelistpages/SmartMeterDeviceListPage.qml @@ -0,0 +1,119 @@ +import QtQuick 2.5 +import QtQuick.Controls 2.1 +import QtQuick.Controls.Material 2.1 +import QtQuick.Layouts 1.1 +import Nymea 1.0 +import "../components" + +DeviceListPageBase { + id: root + + header: GuhHeader { + text: qsTr("Smart meters") + onBackPressed: pageStack.pop() + } + + ListView { + anchors.fill: parent + model: root.devicesProxy + + delegate: ItemDelegate { + id: itemDelegate + width: parent.width + + property bool inline: width > 500 + + property var device: devicesProxy.get(index); + property var deviceClass: engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId); + + bottomPadding: index === ListView.view.count - 1 ? topPadding : 0 + contentItem: Pane { + id: contentItem + Material.elevation: 2 + leftPadding: 0 + rightPadding: 0 + topPadding: 0 + bottomPadding: 0 + + contentItem: ItemDelegate { + leftPadding: 0 + rightPadding: 0 + topPadding: 0 + bottomPadding: 0 + contentItem: ColumnLayout { + Rectangle { + Layout.fillWidth: true + Layout.preferredHeight: app.mediumFont + app.margins + color: Qt.rgba(app.foregroundColor.r, app.foregroundColor.g, app.foregroundColor.b, .05) + RowLayout { + anchors { verticalCenter: parent.verticalCenter; left: parent.left; right: parent.right; margins: app.margins } + Label { + Layout.fillWidth: true + text: model.name + elide: Text.ElideRight + } + ColorIcon { + Layout.preferredHeight: app.iconSize * .5 + Layout.preferredWidth: height + name: "../images/battery/battery-020.svg" + visible: itemDelegate.deviceClass.interfaces.indexOf("battery") >= 0 && itemDelegate.device.states.getState(itemDelegate.deviceClass.stateTypes.findByName("batteryCritical").id).value === true + } + ColorIcon { + Layout.preferredHeight: app.iconSize * .5 + Layout.preferredWidth: height + name: "../images/dialog-warning-symbolic.svg" + visible: itemDelegate.deviceClass.interfaces.indexOf("connectable") >= 0 && itemDelegate.device.states.getState(itemDelegate.deviceClass.stateTypes.findByName("connected").id).value === false + color: "red" + } + } + + } + GridLayout { + id: dataGrid + columns: Math.floor(contentItem.width / 120) + Layout.margins: app.margins + Repeater { + model: ListModel { + ListElement { interfaceName: "smartmeterproducer"; stateName: "totalEnergyProduced" } + ListElement { interfaceName: "smartmeterconsumer"; stateName: "totalEnergyConsumed" } + ListElement { interfaceName: "extendedsmartmeterproducer"; stateName: "currentPower" } + } + + delegate: RowLayout { + id: sensorValueDelegate + visible: itemDelegate.deviceClass.interfaces.indexOf(model.interfaceName) >= 0 + Layout.preferredWidth: contentItem.width / dataGrid.columns + + property var stateType: itemDelegate.deviceClass.stateTypes.findByName(model.stateName) + property var stateValue: stateType ? itemDelegate.device.states.getState(stateType.id) : null + + ColorIcon { + Layout.preferredHeight: app.iconSize * .8 + Layout.preferredWidth: height + Layout.alignment: Qt.AlignVCenter + color: app.interfaceToColor(model.interfaceName) + name: app.interfaceToIcon(model.interfaceName) + } + + Label { + Layout.fillWidth: true + text: sensorValueDelegate.stateValue + ? "%1 %2".arg(sensorValueDelegate.stateValue.value).arg(sensorValueDelegate.stateType.unitString) + : "" + elide: Text.ElideRight + verticalAlignment: Text.AlignVCenter + font.pixelSize: app.smallFont + } + } + } + } + + } + onClicked: { + enterPage(index, false) + } + } + } + } + } +} diff --git a/nymea-app/ui/mainviews/DevicesPageDelegate.qml b/nymea-app/ui/mainviews/DevicesPageDelegate.qml index 99af5924..83b9de65 100644 --- a/nymea-app/ui/mainviews/DevicesPageDelegate.qml +++ b/nymea-app/ui/mainviews/DevicesPageDelegate.qml @@ -25,6 +25,9 @@ MainPageTile { case "light": page = "LightsDeviceListPage.qml" break; + case "smartmeter": + page ="SmartMeterDeviceListPage.qml"; + break; default: page = "GenericDeviceListPage.qml" } @@ -65,6 +68,10 @@ MainPageTile { switch (model.name) { case "sensor": case "weather": + case "smartmeterconsumer": + case "smartmeterproducer": + case "extendedsmartmeterconsumer": + case "extendedsmartmeterproducer": return labelComponent; case "light":