I was going to suggest rearranging your measurments, and this may still be worthwile, but looking at the docs for the select statement I see you can do
select * from EN01_Power, EN01_PowerShift where time >= now() - 14h
Thanks Colin,
but if I re-arrange the select statement - I get one array with just the EN01_Power data.
Do I need an into clause?
The only fields are time and value in both measurements.
show field keys:
I have just tried with the Influxdb In node with a query select * from m1,m2 limit 10
and I get 20 rows with the combined data fields. If the timestamps were the same for some of the samples it might combine them I don't know.
var series = [msg.payload.results[0].series[0].name, msg.payload.results[0].series[1].name];
var labels = [msg.payload.results[0].series[0].name, msg.payload.results[0].series[1].name];
var data0 = "[[";
var thetime0;
for (var i=0; i < msg.payload.results[0].series[0].values.length; i++) {
thetime0 = (msg.payload.results[0].series[0].values[i][0]); // Some manipulation of the time may be required
thetime0 = Date.parse(thetime0);
data0 += '{ "x":' + thetime0 + ', "y":' + msg.payload.results[0].series[0].values[i][1] + '}';
if (i < (msg.payload.results[0].series[0].values.length - 1)) {
data0 += ","
} else {
data0 += "]]"
}
}
var data1 = "[[";
var thetime1;
for (var j=0; j < msg.payload.results[0].series[1].values.length; j++) {
thetime1 = (msg.payload.results[0].series[1].values[j][0]); // Some manipulation of the time may be required
thetime1 = Date.parse(thetime1);
data1 += '{ "x":' + thetime1 + ', "y":' + msg.payload.results[0].series[1].values[j][1] + '}';
if (j < (msg.payload.results[0].series[1].values.length - 1)) {
data1 += ","
} else {
data1 += "]]"
}
}
var data = [data0, data1];
var jsondata = [JSON.parse(data0), JSON.parse(data1)];
//var jsondata = JSON.parse(data1);
msg.payload = [{"series": series, "data": jsondata, "labels": labels}];
msg.playload = data;
return msg;
Get the data in same format as with the earlier solution, but in less steps:
So "data" should be an array, with one element per series and each of those elements should be a simple array of points. You have an array of two elements, which is ok, but you have each of those as an array of 1 element, containing the array of points.
Hi Colin,
thanks for the hint:
the problem lies with the double [] during the conversion, if I use single than it is okay.
So I repost the conversion:
var series = [msg.payload.results[0].series[0].name, msg.payload.results[0].series[1].name];
var labels = [msg.payload.results[0].series[0].name, msg.payload.results[0].series[1].name];
var data0 = "[";
var thetime0;
for (var i=0; i < msg.payload.results[0].series[0].values.length; i++) {
thetime0 = (msg.payload.results[0].series[0].values[i][0]); // Some manipulation of the time may be required
thetime0 = Date.parse(thetime0);
data0 += '{ "x":' + thetime0 + ', "y":' + msg.payload.results[0].series[0].values[i][1] + '}';
if (i < (msg.payload.results[0].series[0].values.length - 1)) {
data0 += ","
} else {
data0 += "]"
}
}
var data1 = "[";
var thetime1;
for (var j=0; j < msg.payload.results[0].series[1].values.length; j++) {
thetime1 = (msg.payload.results[0].series[1].values[j][0]); // Some manipulation of the time may be required
thetime1 = Date.parse(thetime1);
data1 += '{ "x":' + thetime1 + ', "y":' + msg.payload.results[0].series[1].values[j][1] + '}';
if (j < (msg.payload.results[0].series[1].values.length - 1)) {
data1 += ","
} else {
data1 += "]"
}
}
var data = [data0, data1];
var jsondata = [JSON.parse(data0), JSON.parse(data1)];
//var jsondata = JSON.parse(data1);
msg.payload = [{"series": series, "data": jsondata, "labels": labels}];
msg.playload = data;
return msg;