Hey,
I do get pretty accurate MQTT data from my weather station via MQTT but need to format all this content into a string. That's where I am failing.
i do have a payload looking like this:
21.4.2019, 22:37:55node: Raw messages
/home/aussen/wetterstation : msg : Object
object
topic: "/home/aussen/wetterstation"
payload: object
time: "2019-04-21 22:37:54"
model: "Fine Offset Electronics WH1080/WH3080 Weather Station"
msg_type: 0
id: 144
temperature_C: 12
humidity: 44
direction_str: "N"
direction_deg: "0"
speed: 0
gust: 0
rain: 103.8
battery: "OK"
qos: 0
retain: false
_msgid: "ca74f20.6db601"
I need to convert this into a string which should look like this and the values behind the = should be the value from the payload above.
20;DC;Tunex;ID=7B02;TEMP=0001;HUM=99;BAT=OK;
I createad a function node to store the values into variables. var TEMP = msg.payload.temperature_C
var ID = msg.payload.id
var HUM = msg.payload.humidity
var WINDIR = msg.payload.direction_str
var WINGS = msg.payload.direction_deg
var WINSP = msg.payload.speed
var RAIN = msg.payload.rain
var BATT = msg.payload.battery
global.set("TEMP","ID","HUM","WINDIR","WINGS","WINSP","RAIN","BATT")
return msg;
I started with a CHANGE NODE to change the current msg.payload into the beginning of the requested string "20;DC;" . Working like a charm.
But the next function node is killing me as I do not get the variables from above concatenated with a string like "TEMP=" and the value of the TEMP add a ";" and go ahead with the HUM... and so on.