some fixes
This commit is contained in:
parent
a974096dbd
commit
eb17a1ace2
@ -303,7 +303,7 @@ void JsonRpcClient::sendRequest(const QVariantMap &request)
|
|||||||
{
|
{
|
||||||
QVariantMap newRequest = request;
|
QVariantMap newRequest = request;
|
||||||
newRequest.insert("token", m_token);
|
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");
|
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();
|
// qWarning() << "Could not parse json data from nymea" << m_receiveBuffer.left(splitIndex) << error.errorString();
|
||||||
return;
|
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);
|
m_receiveBuffer = m_receiveBuffer.right(m_receiveBuffer.length() - splitIndex - 1);
|
||||||
if (!m_receiveBuffer.isEmpty()) {
|
if (!m_receiveBuffer.isEmpty()) {
|
||||||
staticMetaObject.invokeMethod(this, "dataReceived", Qt::QueuedConnection, Q_ARG(QByteArray, QByteArray()));
|
staticMetaObject.invokeMethod(this, "dataReceived", Qt::QueuedConnection, Q_ARG(QByteArray, QByteArray()));
|
||||||
|
|||||||
@ -202,6 +202,8 @@ void LogsModelNg::logsReply(const QVariantMap &data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (newBlock.isEmpty()) {
|
if (newBlock.isEmpty()) {
|
||||||
|
m_busy = false;
|
||||||
|
emit busyChanged();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,10 +250,10 @@ void LogsModelNg::logsReply(const QVariantMap &data)
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
if (m_graphSeries->count() == 0) {
|
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()));
|
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()));
|
m_graphSeries->append(QPointF(entry->timestamp().toMSecsSinceEpoch(), entry->value().toReal()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -135,5 +135,6 @@
|
|||||||
<file>ui/customviews/GenericTypeGraphPre110.qml</file>
|
<file>ui/customviews/GenericTypeGraphPre110.qml</file>
|
||||||
<file>ui/customviews/GenericTypeGraph.qml</file>
|
<file>ui/customviews/GenericTypeGraph.qml</file>
|
||||||
<file>ui/devicepages/SmartMeterDevicePage.qml</file>
|
<file>ui/devicepages/SmartMeterDevicePage.qml</file>
|
||||||
|
<file>ui/devicelistpages/SmartMeterDeviceListPage.qml</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
@ -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 {
|
CheckDelegate {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
text: qsTr("Return to home on idle")
|
text: qsTr("Return to home on idle")
|
||||||
|
|||||||
119
nymea-app/ui/devicelistpages/SmartMeterDeviceListPage.qml
Normal file
119
nymea-app/ui/devicelistpages/SmartMeterDeviceListPage.qml
Normal file
@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -25,6 +25,9 @@ MainPageTile {
|
|||||||
case "light":
|
case "light":
|
||||||
page = "LightsDeviceListPage.qml"
|
page = "LightsDeviceListPage.qml"
|
||||||
break;
|
break;
|
||||||
|
case "smartmeter":
|
||||||
|
page ="SmartMeterDeviceListPage.qml";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
page = "GenericDeviceListPage.qml"
|
page = "GenericDeviceListPage.qml"
|
||||||
}
|
}
|
||||||
@ -65,6 +68,10 @@ MainPageTile {
|
|||||||
switch (model.name) {
|
switch (model.name) {
|
||||||
case "sensor":
|
case "sensor":
|
||||||
case "weather":
|
case "weather":
|
||||||
|
case "smartmeterconsumer":
|
||||||
|
case "smartmeterproducer":
|
||||||
|
case "extendedsmartmeterconsumer":
|
||||||
|
case "extendedsmartmeterproducer":
|
||||||
return labelComponent;
|
return labelComponent;
|
||||||
|
|
||||||
case "light":
|
case "light":
|
||||||
|
|||||||
Reference in New Issue
Block a user