more tuning on smartmeter stuff
This commit is contained in:
parent
eb17a1ace2
commit
8244c4dc5e
@ -118,6 +118,15 @@ QVariant Devices::data(const QModelIndex &index, int role) const
|
||||
if (interfaces.contains("notifications")) {
|
||||
return "notifications";
|
||||
}
|
||||
if (interfaces.contains("smartmeter")) {
|
||||
return "smartmeter";
|
||||
}
|
||||
if (interfaces.contains("heating")) {
|
||||
return "heating";
|
||||
}
|
||||
if (interfaces.contains("evcharger")) {
|
||||
return "evcharger";
|
||||
}
|
||||
return "uncategorized";
|
||||
}
|
||||
|
||||
|
||||
@ -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()));
|
||||
|
||||
@ -151,5 +151,7 @@
|
||||
<file>ui/images/zoom-out.svg</file>
|
||||
<file>ui/images/zoom-in.svg</file>
|
||||
<file>ui/images/smartmeter.svg</file>
|
||||
<file>ui/images/radiator.svg</file>
|
||||
<file>ui/images/ev-charger.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
@ -124,3 +124,6 @@ BR=$$BRANDING
|
||||
target.path = /usr/bin
|
||||
INSTALLS += target
|
||||
|
||||
DISTFILES += \
|
||||
ruletemplates/smartmetertemplates.json
|
||||
|
||||
|
||||
@ -3,5 +3,6 @@
|
||||
<file>ruletemplates/buttontemplates.json</file>
|
||||
<file>ruletemplates/notificationtemplates.json</file>
|
||||
<file>ruletemplates/accesscontroltemplates.json</file>
|
||||
<file>ruletemplates/smartmetertemplates.json</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
84
nymea-app/ruletemplates/smartmetertemplates.json
Normal file
84
nymea-app/ruletemplates/smartmetertemplates.json
Normal file
@ -0,0 +1,84 @@
|
||||
{
|
||||
"templates": [
|
||||
{
|
||||
"interfaceName": "extendedsmartmeterproducer",
|
||||
"description": "Charge my car while producing energy.",
|
||||
"ruleNameTemplate": "Smart car charging",
|
||||
"stateEvaluatorTemplate": {
|
||||
"stateDescriptorTemplate": {
|
||||
"interfaceName": "extendedsmartmeterproducer",
|
||||
"interfaceState": "currentPower",
|
||||
"operator": "ValueOperatorGreater",
|
||||
"value": 0,
|
||||
"selectionId": 0
|
||||
}
|
||||
},
|
||||
"ruleActionTemplates": [
|
||||
{
|
||||
"interfaceName": "evcharger",
|
||||
"interfaceAction": "power",
|
||||
"selectionId": 1,
|
||||
"params": [
|
||||
{
|
||||
"name": "power",
|
||||
"value": true
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"ruleExitActionTemplates": [
|
||||
{
|
||||
"interfaceName": "evcharger",
|
||||
"interfaceAction": "power",
|
||||
"selectionId": 1,
|
||||
"params": [
|
||||
{
|
||||
"name": "power",
|
||||
"value": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"interfaceName": "extendedsmartmeterproducer",
|
||||
"description": "Turn on heating while producing energy.",
|
||||
"ruleNameTemplate": "Smart heating",
|
||||
"stateEvaluatorTemplate": {
|
||||
"stateDescriptorTemplate": {
|
||||
"interfaceName": "extendedsmartmeterproducer",
|
||||
"interfaceState": "currentPower",
|
||||
"operator": "ValueOperatorGreater",
|
||||
"value": 0,
|
||||
"selectionId": 0
|
||||
}
|
||||
},
|
||||
"ruleActionTemplates": [
|
||||
{
|
||||
"interfaceName": "heating",
|
||||
"interfaceAction": "power",
|
||||
"selectionId": 1,
|
||||
"params": [
|
||||
{
|
||||
"name": "power",
|
||||
"value": true
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"ruleExitActionTemplates": [
|
||||
{
|
||||
"interfaceName": "heating",
|
||||
"interfaceAction": "power",
|
||||
"selectionId": 1,
|
||||
"params": [
|
||||
{
|
||||
"name": "power",
|
||||
"value": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -53,7 +53,7 @@ ApplicationWindow {
|
||||
rootItem.handleCloseEvent(close)
|
||||
}
|
||||
|
||||
property var supportedInterfaces: ["light", "weather", "sensor", "media", "garagegate", "awning", "shutter", "blind", "smartmeter", "accesscontrol", "button", "notifications", "inputtrigger", "outputtrigger", "gateway"]
|
||||
property var supportedInterfaces: ["light", "weather", "sensor", "media", "garagegate", "awning", "shutter", "blind", "heating", "smartmeter", "evcharger", "accesscontrol", "button", "notifications", "inputtrigger", "outputtrigger", "gateway"]
|
||||
function interfaceToString(name) {
|
||||
switch(name) {
|
||||
case "light":
|
||||
@ -94,7 +94,15 @@ ApplicationWindow {
|
||||
case "accesscontrol":
|
||||
return qsTr("Access control");
|
||||
case "smartmeter":
|
||||
return qsTr("Smart meter");
|
||||
case "smartmeterproducer":
|
||||
case "smartmeterconsumer":
|
||||
case "extendedsmartmeterproducer":
|
||||
case "extendedsmartmeterconsumer":
|
||||
return qsTr("Smart meters");
|
||||
case "heating":
|
||||
return qsTr("Heatings");
|
||||
case "evcharger":
|
||||
return qsTr("EV-chargers");
|
||||
case "uncategorized":
|
||||
return qsTr("Uncategorized")
|
||||
default:
|
||||
@ -181,6 +189,12 @@ ApplicationWindow {
|
||||
case "extendedsmartmeterconsumer":
|
||||
case "extendedsmartmeterproducer":
|
||||
return Qt.resolvedUrl("images/smartmeter.svg")
|
||||
case "heating":
|
||||
case "extendedheating":
|
||||
return Qt.resolvedUrl("images/radiator.svg")
|
||||
case "evcharger":
|
||||
case "extendedevcharger":
|
||||
return Qt.resolvedUrl("images/ev-charger.svg")
|
||||
case "connectable":
|
||||
return Qt.resolvedUrl("images/stock_link.svg")
|
||||
default:
|
||||
|
||||
@ -13,6 +13,7 @@ Item {
|
||||
|
||||
property var device: null
|
||||
property var stateType: null
|
||||
property int roundTo: 2
|
||||
readonly property var valueState: device.states.getState(stateType.id)
|
||||
readonly property var deviceClass: engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
|
||||
readonly property bool hasConnectable: deviceClass.interfaces.indexOf("connectable") >= 0
|
||||
@ -56,7 +57,7 @@ Item {
|
||||
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
text: root.valueState.value + " " + root.stateType.unitString
|
||||
text: 1.0 * Math.round(root.valueState.value * Math.pow(10, root.roundTo)) / Math.pow(10, root.roundTo) + " " + root.stateType.unitString
|
||||
font.pixelSize: app.largeFont
|
||||
}
|
||||
|
||||
|
||||
@ -74,14 +74,26 @@ DeviceListPageBase {
|
||||
Layout.margins: app.margins
|
||||
Repeater {
|
||||
model: ListModel {
|
||||
ListElement { interfaceName: "smartmeterproducer"; stateName: "totalEnergyProduced" }
|
||||
ListElement { interfaceName: "smartmeterconsumer"; stateName: "totalEnergyConsumed" }
|
||||
ListElement { interfaceName: "extendedsmartmeterproducer"; stateName: "currentPower" }
|
||||
Component.onCompleted: {
|
||||
if (itemDelegate.deviceClass.interfaces.indexOf("smartmeterproducer") >= 0) {
|
||||
append( {interfaceName: "smartmeterproducer", stateName: "totalEnergyProduced" })
|
||||
}
|
||||
if (itemDelegate.deviceClass.interfaces.indexOf("smartmeterconsumer") >= 0) {
|
||||
append( {interfaceName: "smartmeterconsumer", stateName: "totalEnergyConsumed" })
|
||||
}
|
||||
var added = false;
|
||||
if (itemDelegate.deviceClass.interfaces.indexOf("extendedsmartmeterproducer") >= 0) {
|
||||
append({interfaceName: "extendedsmartmeterconsumer", stateName: "currentPower"});
|
||||
added = true;
|
||||
}
|
||||
if (!added && itemDelegate.deviceClass.interfaces.indexOf("extendedsmartmeterconsumer") >= 0) {
|
||||
append({interfaceName: "extendedsmartmeterconsumer", 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)
|
||||
@ -98,7 +110,7 @@ DeviceListPageBase {
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
text: sensorValueDelegate.stateValue
|
||||
? "%1 %2".arg(sensorValueDelegate.stateValue.value).arg(sensorValueDelegate.stateType.unitString)
|
||||
? "%1 %2".arg(1.0 * Math.round(sensorValueDelegate.stateValue.value * 100000) / 100000).arg(sensorValueDelegate.stateType.unitString)
|
||||
: ""
|
||||
elide: Text.ElideRight
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
@ -106,8 +118,7 @@ DeviceListPageBase {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
onClicked: {
|
||||
enterPage(index, false)
|
||||
|
||||
@ -38,6 +38,7 @@ DevicePageBase {
|
||||
stateType: root.deviceClass.stateTypes.findByName(model.stateTypeName)
|
||||
color: app.interfaceToColor(model.interface)
|
||||
iconSource: app.interfaceToIcon(model.interface)
|
||||
roundTo: 5
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
6537
nymea-app/ui/images/ev-charger.svg
Normal file
6537
nymea-app/ui/images/ev-charger.svg
Normal file
File diff suppressed because it is too large
Load Diff
|
After Width: | Height: | Size: 184 KiB |
71
nymea-app/ui/images/radiator.svg
Normal file
71
nymea-app/ui/images/radiator.svg
Normal file
@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
version="1.1"
|
||||
width="96"
|
||||
viewBox="0 0 96 96.000001"
|
||||
height="96"
|
||||
id="svg4874">
|
||||
<defs
|
||||
id="defs875" />
|
||||
<metadata
|
||||
id="metadata4879">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<path
|
||||
id="rect4199"
|
||||
style="color:#000000;fill:#808080;stroke-width:2.82842588"
|
||||
d="m 45.99995,81.99995 h 4 V 18 h -4 z" />
|
||||
<rect
|
||||
id="rect4782"
|
||||
style="color:#000000;fill:none"
|
||||
transform="rotate(90)"
|
||||
height="96"
|
||||
width="96"
|
||||
y="-96"
|
||||
x="-2.7465819e-06" />
|
||||
<path
|
||||
id="path4179"
|
||||
style="color:#000000;font-variant-ligatures:none;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;text-transform:none;white-space:normal;shape-padding:0;isolation:auto;mix-blend-mode:normal;solid-color:#000000;fill:#808080;color-rendering:auto;image-rendering:auto;shape-rendering:auto"
|
||||
d="m 29.976,12.001 c -5.0328,0.05818 -8.7136,-0.12028 -11.725,1.541 -1.5055,0.83064 -2.6968,2.2356 -3.3555,3.9902 -0.65866,1.7547 -0.89648,3.8383 -0.89648,6.4688 v 52 c 0,2.6304 0.23782,4.7121 0.89648,6.4668 0.65866,1.7546 1.85,3.1596 3.3555,3.9902 3.011,1.6613 6.6918,1.4848 11.725,1.543 h 0.01172 36.023 0.01172 c 5.0328,-0.0582 8.7136,0.11832 11.725,-1.543 1.5055,-0.83064 2.6968,-2.2356 3.3555,-3.9902 0.65866,-1.7547 0.89648,-3.8364 0.89648,-6.4668 v -52 c 0,-2.6304 -0.23782,-4.7141 -0.89648,-6.4688 -0.66,-1.759 -1.851,-3.163 -3.356,-3.994 -3.011,-1.661 -6.692,-1.483 -11.725,-1.541 h -0.01172 -36.023 -0.01172 z m 0.02344,4 h 36 c 5.0383,0.05877 8.3519,0.23688 9.8164,1.0449 0.73364,0.40478 1.1527,0.85295 1.543,1.8926 0.39025,1.0396 0.64062,2.6929 0.64062,5.0625 v 52 c 0,2.3696 -0.25037,4.0229 -0.64062,5.0625 -0.39025,1.0396 -0.80933,1.4878 -1.543,1.8926 -1.4645,0.80804 -4.7782,0.98616 -9.8164,1.0449 H 30.02244 29.999 c -5.0383,-0.0588 -8.3519,-0.23688 -9.8164,-1.0449 -0.73364,-0.40478 -1.1508,-0.85296 -1.541,-1.8926 -0.39025,-1.0396 -0.64258,-2.6929 -0.64258,-5.0625 v -52 c 0,-2.3696 0.25232,-4.0229 0.64258,-5.0625 0.39025,-1.0396 0.80738,-1.4878 1.541,-1.8926 1.4645,-0.80804 4.7782,-0.98616 9.8164,-1.0449 z" />
|
||||
<path
|
||||
d="m 29.99995,81.99995 h 4 V 18 h -4 z"
|
||||
style="color:#000000;fill:#808080;stroke-width:2.82842588"
|
||||
id="path2070" />
|
||||
<path
|
||||
id="path2072"
|
||||
style="color:#000000;fill:#808080;stroke-width:2.82842588"
|
||||
d="m 61.99995,81.99995 h 4 V 18 h -4 z" />
|
||||
<path
|
||||
id="path2074"
|
||||
style="color:#000000;fill:#808080;stroke-width:1.00000155"
|
||||
d="m 16,31.999975 v -4 H 7.999975 v 4 z" />
|
||||
<path
|
||||
d="m 87.999925,31.999975 v -4 H 80 v 4 z"
|
||||
style="color:#000000;fill:#808080;stroke-width:0.99999529"
|
||||
id="path2076" />
|
||||
<path
|
||||
id="path2078"
|
||||
style="color:#000000;fill:#808080;stroke-width:1.06065571"
|
||||
d="m 87.999925,71.999975 v -4 H 79 v 4 z" />
|
||||
<path
|
||||
d="m 16,71.999975 v -4 H 7.999975 v 4 z"
|
||||
style="color:#000000;fill:#808080;stroke-width:1.00000155"
|
||||
id="path2080" />
|
||||
<path
|
||||
id="path2082"
|
||||
style="color:#000000;fill:#808080;stroke-width:0.99999529"
|
||||
d="m 87.999963,26.000013 h -4 v 7.999925 h 4 z" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.7 KiB |
Reference in New Issue
Block a user