--
http://nodered.org
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/589fcb8b-1b5f-4265-8312-05e5d5737198%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
function code:
var now1 = new Date();var CommsStatus;var sql = [];var outputs = [];var msg1, msg2, msg3, msg4, msg5, msg6, msg7, msg8, msg9, msg10, msg11, msg12, msg13, msg14 , msg15 , msg16, msg17, msg18, msg19, msg20, msg21 = {};var lengthvar m = {};var msgrtn = 'arroz';
//Recepeção varios msg.payload's atravez do topiccontext.data = context.data || new Object();context.data1 = context.data || new Object();length = msg.payload.results[0].series[0].values.length;
for (i = 0; i < length; i++) { context.data[i] = msg.payload.results[0].series[0].values[i][0]; context.data1[i] = msg.payload.results[0].series[0].values[i][1];
}
//estrutura para criar grafico de barras duplas m.labels = ["Time", "Value"]; m.series = ['time', 'Value']; m.data = [ [context.data[i]], [context.data1[i]],
]return {payload:[m]};
[
{
"series": [
"ActiveEnergy"
],
"labels": [
"time",
"value"
],
"data": [
[
{
"x": 1515542400000,
"y": 2.7
}
],
[
{
"x": 1515549600000,
"y": 2.8
}
]
]
}
]payload.results.[{
"series": series.[name],
"labels": series.[columns],
"data": [
series.values.[{
"x": $[0]*1000,
"y": $[1]
}]
]
}]--
http://nodered.org
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/e725bb3b-4d18-4f90-8cf1-2aba0df4d5b1%40googlegroups.com.
Finally, just to give you an alternate solution, you should check out the Jsonata syntax available in a change node.
The function I think is working, but the graph does not connect the points: s
My influx query
select last(value) - first(value) from ActiveEnergy where time > '2018-01-11T00:00:00Z' and time < '2018-01-12T00:00:00Z' group by time(1h) fill(null)
Data from influx query
{"_msgid":"69d03669.962fc8","topic":"","payload":{"results":[{"series":[{"name":"ActiveEnergy","columns":["time",""],"values":[[1515628800,5.600000000000364],[1515632400,5.699999999999818],[1515636000,5.5],[1515639600,5.699999999999818],[1515643200,5.600000000000364],[1515646800,5.5],[1515650400,7],[1515654000,6.599999999999454],[1515657600,10.5],[1515661200,12],[1515664800,13.099999999999454],[1515668400,15.400000000000546],[1515672000,13.399999999999636],[1515675600,9.200000000000728],[1515679200,13.5],[1515682800,13.599999999999454],[1515686400,14.100000000000364],[1515690000,15.599999999999454],[1515693600,12.599999999999454],[1515697200,7.099999999999454],[1515700800,5.600000000000364],[1515704400,5.5],[1515708000,5.400000000000546],[1515711600,5.600000000000364]]}]}]}}payload.results.[{
"series": series.[name],
"labels": series.[columns], "data": [
[series.values.{
"x": $[0]*1000,
"y": $round($[1], 2)
}]
]
}]
{
"_msgid": "1d3299b9.736ca6",
"topic": "",
"payload": {
"results": [
{
"series": [
{
"name": "indexeau",
"columns": [
"time",
"value"
],
"values": [
[
1519906805,
2174.041
],
[
1519906807,
2174.041
],
[
1519906809,
2174.041
]
]
},
{
"name": "indexgaz",
"columns": [
"time",
"value"
],
"values": [
[
1519906820,
2000.041
],
[
1519906822,
2000.041
],
[
1519906823,
2000.041
],
[
1519906826,
2000.041
]
]
}
]
}
]
}
}payload.results.[{
"series": series.name,
"labels": series[0].columns,
"data": [
series.[values.{
"x": $[0]*1000,
"y": $round($[1], 3)
}]
]
}] "data": [
series.[(
$mult := name = "indexeau" ? 2: name = "indexgaz" ? 3 : 1;
values.{
"x": $[0]*1000,
"y": $round($[1], 3) * $mult
}
)]
](
$ts := $flowContext('tempSerie');
$series := $ts.**.columns[1];
$data := $ts.[
results.series.$map(
values,
function($v)
{
{
"x": $v[0],
"y": $v[1]
}
}
)
];
[
{
"series": $series,
"data": $data
}
]
)
[{"id":"d1c59fcb.25593","type":"influxdb in","z":"b9acf092.52dba8","influxdb":"d268d9d8.f29f2","name":"WG SELECT Query (Raw)","query":"SELECT mean(\"temperature\") AS \"Wintergarten\" FROM \"rwhome\".\"autogen\".\"temperature\" WHERE time > now() - 1d AND \"device\"='HEQ0031167:1' GROUP BY time(10m) ","rawOutput":true,"precision":"ms","retentionPolicy":"","x":421,"y":164,"wires":[["ac50e102.e5729","478c7f4f.227de8"]]},{"id":"d3a78ea5.174e6","type":"inject","z":"b9acf092.52dba8","name":"eyery 10 minutes","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":"","x":176,"y":163,"wires":[["d1c59fcb.25593"]]},{"id":"3e688dd4.4804ba","type":"ui_chart","z":"b9acf092.52dba8","name":"myTemp Chart","group":"45ccb249.d78b94","order":1,"width":"6","height":"5","label":"Home Temperatures","chartType":"line","legend":"true","xformat":"auto","interpolate":"linear","nodata":"hole Daten","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"86400","cutout":0,"useOneColor":false,"colors":["#1F77B4","#AEC7E8","#FF7F0E","#2CA02C","#98DF8A","#D62728","#FF9896","#9467BD","#C5B0D5"],"useOldStyle":false,"x":705,"y":809,"wires":[[],[]]},{"id":"2d7399c.bbf80e6","type":"comment","z":"b9acf092.52dba8","name":"WG","info":"","x":362.5,"y":111,"wires":[]},{"id":"cdfd959d.e9cec","type":"influxdb in","z":"b9acf092.52dba8","influxdb":"d268d9d8.f29f2","name":"Garten SELECT Query (Raw)","query":"SELECT mean(\"temperature\") AS \"Garten\" FROM \"rwhome\".\"autogen\".\"temperature\" WHERE time > now() - 1d AND \"device\"='HEQ0118187:1' GROUP BY time(10m) ","rawOutput":true,"precision":"ms","retentionPolicy":"","x":432,"y":332,"wires":[["8cad15d8.1bfdc"]]},{"id":"31f91162.26146e","type":"comment","z":"b9acf092.52dba8","name":"Garten","info":"","x":363.5,"y":297,"wires":[]},{"id":"8f1a3280.9eb8b8","type":"influxdb in","z":"b9acf092.52dba8","influxdb":"d268d9d8.f29f2","name":"Keller SELECT Query (Raw)","query":"SELECT mean(\"temperature\") AS \"Keller\" FROM \"rwhome\".\"autogen\".\"temperature\" WHERE time > now() - 1d AND \"device\"='HEQ0355273:1' GROUP BY time(10m) ","rawOutput":true,"precision":"ms","retentionPolicy":"","x":431,"y":503,"wires":[["69fcf38c.049194"]]},{"id":"8b006b03.5451a","type":"comment","z":"b9acf092.52dba8","name":"Keller","info":"","x":355.5,"y":465,"wires":[]},{"id":"dde198ca.738458","type":"influxdb in","z":"b9acf092.52dba8","influxdb":"d268d9d8.f29f2","name":"WZ SELECT Query (Raw)","query":"SELECT mean(\"temperature\") AS \"Wohnzimmer\" FROM \"rwhome\".\"autogen\".\"temperature\" WHERE time > now() - 1d AND \"device\"='HEQ0355711:1' GROUP BY time(10m) ","rawOutput":true,"precision":"ms","retentionPolicy":"","x":411,"y":678,"wires":[["dbae278d.e4f95"]]},{"id":"4383578b.13b49","type":"comment","z":"b9acf092.52dba8","name":"Wohnzimmer","info":"","x":376.5,"y":640,"wires":[]},{"id":"ac50e102.e5729","type":"change","z":"b9acf092.52dba8","name":"","rules":[{"t":"set","p":"temperatureSerie[0]","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":429.5,"y":212,"wires":[["cdfd959d.e9cec"]]},{"id":"8cad15d8.1bfdc","type":"change","z":"b9acf092.52dba8","name":"","rules":[{"t":"set","p":"temperatureSerie[1]","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":429,"y":381,"wires":[["8f1a3280.9eb8b8"]]},{"id":"69fcf38c.049194","type":"change","z":"b9acf092.52dba8","name":"","rules":[{"t":"set","p":"temperatureSerie[2]","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":547,"wires":[["dde198ca.738458"]]},{"id":"dbae278d.e4f95","type":"change","z":"b9acf092.52dba8","name":"","rules":[{"t":"set","p":"temperatureSerie[3]","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":422,"y":730,"wires":[["d8e5e8af.09e2d8"]]},{"id":"d8e5e8af.09e2d8","type":"change","z":"b9acf092.52dba8","name":"prepare line chart data structure","rules":[{"t":"set","p":"payload","pt":"msg","to":"(\t $ts := $flowContext('temperatureSerie');\t $series := $ts.**.columns[1];\t $data := $ts.[results.series.$map(values,\t function($v) \t {\t {\t \"x\": $v[0],\t \"y\": $v[1]\t }\t }\t )];\t [\t {\t \"series\": $series,\t \"data\": $data\t }\t ]\t)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":426,"y":810,"wires":[["3e688dd4.4804ba","cd7a6b6f.1ee5d8"]]},{"id":"cd7a6b6f.1ee5d8","type":"debug","z":"b9acf092.52dba8","name":"neu","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":688,"y":865,"wires":[]},{"id":"478c7f4f.227de8","type":"debug","z":"b9acf092.52dba8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":694.5,"y":164,"wires":[]},{"id":"d268d9d8.f29f2","type":"influxdb","z":"","hostname":"192.168.99.139","port":"8086","protocol":"http","database":"rwhome","name":"rwhome","usetls":false,"tls":"dbdbee3a.f5c3c8"},{"id":"45ccb249.d78b94","type":"ui_group","z":"","name":"carts","tab":"117d29fb.cbb31e","order":1,"disp":true,"width":"6"},{"id":"dbdbee3a.f5c3c8","type":"tls-config","z":"","name":"local-tls","cert":"","key":"","ca":"","certname":"","keyname":"","caname":"","verifyservercert":false},{"id":"117d29fb.cbb31e","type":"ui_tab","z":"","name":"Homematic","icon":"dashboard","order":1}]Hello,
Your answer helped me to plot a measurement with ui_chart.
But how to modify the JSONata to draw several series on the same graph:
...