Hi,
... please could someone help me how "correctly" write values (with tags) to influxdb.
The values in influxdb are not correctly writing (with " " symbol - like STRING)
Thanks
What is coming out of mqtt?
in node-red it looks like ..

There is a fairly large issue with InfluxDB that, once you have written to a field, it takes the data type that you first wrote to it. So if you meant to send a float for example but the first time you outputted a string - you have an issue.
There are only two ways around this.
.. nope .. new field (which is created after drop) is again like "string" ... the nodered send like string and not like value
... I think nodered have issue with multiple value in payload. I see the value like Ts: "23441" and not Ts: 23441 in debug window (see
).
modul JSON make this, but only with one value - one msg.payload .. and also in influxdb is like value
I believe that the problem is that the values of Ts etc in the string from the MQTT node are already strings. Are they strings in the object you are sending to MQTT?
If you can't change it at that end then you will need to convert then to numbers after the JSON node. You can do that to each one in a function node using the JavaScript Number() function.
take a look at this: https://cookbook.nodered.org/mqtt/receive-json
thanks for tips, but not working .. still same
Put a debug nde after the JSON node and set it to display the complter msg object. What does it show?
Hi,
I had the same problem and fixed using a function node to cast all strings to int and float where possible:
function TryParseInt(str, defaultValue) { let v=parseInt(str); return v==str ? v : defaultValue; }
function TryParseFloat(str, defaultValue) { let v= parseFloat(str); return v==str ? v : defaultValue; }
var payload=msg.payload;
for (var key in payload) {
if (payload.hasOwnProperty(key)) {
payload[key]=TryParseInt(payload[key],payload[key]);
payload[key]=TryParseFloat(payload[key],payload[key]);
}
}
msg.payload=payload;
return msg;
This information (that InfluxDB takes the data type first wrote to it) has just saved me a huge amount of time in debugging.
Thanks!