Passing 2 values into single influxdb node

Hello, in the influxdb node, you have to manually type the measurement name.
I am able to extract the value and the value name from an array.

I was wondering if I could also pass the value name into the influxdb node thus not requiring manual input on the measurement name.

Welcome subwayfootlong!

Do you know this thread?

You can pass the measurement name in the message. Read the help text for the influx node.

Ok maybe I'm looking into this all wrongly.
Here is the json format of what the sensor is outputting

[{"name":"BRTC CISS Sensor 004_Humidity","description":"","unit":"% rH","values":[{"value":60.96,"timestamp":"2021-05-20T06:27:14.265Z"}]}]

Currently, I'm using a function node to extract the value from the array and connected it to the influxdb output node to upload it.

value=msg.payload[0].value[0].value;
msg.payload=value;
return msg;

But because of this code, I have to manually set the measurement name in the influxdb output node.

What I want is to send both the measurement name and the value so that I dont have to manually set the measurement name.

From @Colin 's reply, I read the help text and that msg.measurement should contain the measurement name so I edited my code to

value=msg.payload[0].value[0].value;
name=msg.payload[0].name;
msg.payload=value;
msg.measurement=name;
return msg;

However I get

"Error: A 400 Bad Request error occurred:{"error":"unable to parse 'BRTC CISS Sensor 004_Humidity value=60.96': invalid field format"}

Am I doing everything wrongly?

Whenever you have an unexpected error from a node the first thing to do is to connect a debug node showing what is going into the node. So connect a debug node to the output of your function and set it to Show Complete Message and check what it shows.
Screenshot it here if you think it looks ok.
What influx node are you using?


I am using the influxdb out node from the node-red-contrib-influxdb pallete

Does it work if you use a measurement name without spaces?

What version of influxdb are you using?

You were right!
The measurement name cant have spaces....
I totally forgot about the fundamentals.
Thanks Colin

In fact I believe that you should be able to have spaces in the measurement name, but Influx has been a bit flaky in the past with them (perhaps even in v2.0, I don't know). I just don't use spaces, using underscore instead.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.