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.
Colin
19 May 2021 13:43
3
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?
Colin
20 May 2021 08:22
6
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
Colin
20 May 2021 09:52
8
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
Colin
21 May 2021 09:15
10
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.
system
Closed
4 June 2021 09:16
11
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.