{"Sequence":35851,"Watt": 7372.8,"kWh":18889.219,"battery":100,"FreqErr":0.57}
I've been trying to figure out if I could use parts from my other function that adds information to my DB from different topics using msg.parts
var tokens = msg.topic.split("/");
var dest = tokens[tokens.length-1];
msg.url ="http://192.168.1.15:8086/write?db=nodered";
msg.payload = tokens[2] + ",measurement=" + tokens[3] + ",device=" + tokens[1] + " value=" + msg.payload;
return msg;
Anyone that can lend a hand or point me in the right direction would be helpful!
msg.url ="http://192.168.1.15:8086/write?db=sparsnas";
msg.payload = "sparsnas" + ",measurement=Watt " + " value=" + msg.payload.Watt;
return msg;
You might also find the JSONata facility of the change node of considerable use ;-)
On Tuesday, December 5, 2017 at 1:33:58 PM UTC, Erik Näsström wrote:
I'm trying to figure out how to parse a json string that's delivered through mqtt to a format that I can store in my influxdb database:
{"Sequence":35851,"Watt": 7372.8,"kWh":18889.219,"battery":100,"FreqErr":0.57}
I've been trying to figure out if I could use parts from my other function that adds information to my DB from different topics using msg.parts