Hello all! I have probably very easy issue to solve but I do not know how to do it.
I have created the flow where data is sent to MQTT server. That works fine, but I would like to use same values in MQTT in and send the same values to Influxdb. My issue is that I do not know how to parse string to number.
This is my function that sends the data to the MQTT server node
let room= msg.payload;
msg.payload = '{"loc":"' + room.loc + '", "device":"' + room.device + '", "value":' + room.temperature.toFixed(2) + '}';
msg.topic = 'room/basement';
return msg;
My function from MQTT in node to Influxdb node:
let t = { payload: temperature, measurement: "temperature"};
return [t];
Error is:
[node: Make temp measurement]
msg.payload : undefined
I have tried just random values, and data flows to Influxdb as it should but values are not from the MQTT server, example:
let t = { payload: Math.random() * 15 + 20, measurement: "temperature"};
I do not know how should I retrieve the values from a previous function? I know that value supposed to be number, not string or object.
Issue is here:
> node: debug 206
> room/basement : msg.payload : Object
> object
> loc: "room"
> device: "sensor"
> value: "34.94"
Error is:
> node: Influxdb out
> msg : string[24]
>
> "No measurement specified"
Appreciate all the help!
UPDATE:
Function node is now:
const room = msg.payload;
msg.payload = {
loc: room.loc,
device: room.device,
value: Number(room.temperature)
}
msg.topic = 'room/basement';
msg.measurement = 'temperature';
return msg;
Same error: