Transfer Node Red data to Influx - TypeError: points.forEach is not a function

I am a beginner and have little experience with Node Red and InfluxDB. I want to send data to the InfluxDB database. The data are stored in flow.context and it is all of type float.

In a function node I create the followung object:

msg.payload = {
“SumE” : flow.get(“SumE_AC”),
“TagE” : flow.get(“TagE_AC”),
“Pac” : flow.get(“P_AC”),
“maxPac” : flow.get(“maxP_AC”),
“Pdc” : flow.get(“P_DC”),
“maxPdc” : flow.get(“maxP_DC”),
“Temp” : flow.get(“PV_TempWR”),
“Uac” : flow.get(“U_AC”),
“Fac” : flow.get(“F_AC”)
}
return msg;

which I send on to a node ‘influx’ PV garage.

here I get the following error message:
5/11/2023, 17:59:45node: pv-garage.
msg : error
“TypeError: points.forEach is not a function”.

and this is the msg.load:

HM-800_Garage/HM-800_Garage/ch0/Temp : msg.payload : Object
object
SumE: 186,842
TagE: 3241
Pac: 158.8
maxPac: 522
Pdc: 166.8
maxPdc: 548.3
Temp: 36.6
Uac: 225.5
Fac: 50.01

Where is my problem that the node ‘influx’ PV garage brings this error message.

InfluxDB shell version: 1.8.10
Node Red version 2.1.0
beides läuft auf einem Raspberry Pi.
PRETTY_NAME=“Raspbian GNU/Linux 10 (buster)”
NAME=“Raspbian GNU/Linux”
VERSION_ID=“10”
VERSION=“10 (buster)”
VERSION_CODENAME=buster
ID=raspbian

I think you error is within the function in your node.

image
use debug node to see exactly what the payload is being sent to the InfluxDB output node.

the help on Output node is clear on what to expect as input:

The fields and tags to write are in msg.payload. If msg.payload is a string, number, or boolean, it will be written as a single value to the specified measurement (called value).

If msg.payload is an object containing multiple properties, the fields will be written to the measurement.

If msg.payload is an array containing two objects, the first object will be written as the set of named fields, the second is the set of named tags.

Finally, if msg.payload is an array of arrays, it will be written as a series of points containing fields and tags.

If the measurement field is not set in the node configuration, the user can send in data with a specified measurement name in msg.measurement to overwrite the measurement field in the configuration of the node.

this is an example of my payload to the Output node:

[{"_status":"Aknowledge","value_avg":"0i","user":"fernando","comments":"this is a test for the Output Node"},{"name":"tag1"}]

Thank you for your support.

I have added a debug node.
In the output, unfortunately, I do not see more than before.
Output

How do I have to adjust my function node?

msg.payload = {
	"SumE"   : flow.get("SumE_AC"),
	"TagE"   : flow.get("TagE_AC"),
	"Pac"    : flow.get("P_AC"),
	"maxPac" : flow.get("maxP_AC"),
	"Pdc"    : flow.get("P_DC"),
	"maxPdc" : flow.get("maxP_DC"),
	"Temp"   : flow.get("PV_TempWR"),
	"Uac"    : flow.get("U_AC"),
	"Fac"    : flow.get("F_AC")
}
  return msg;

This is the flow:
Object

I’m not at the computer right now, but the object looks good however I’m not 100% sure about this but i believe that if the number is float should be in the format 100.0, MaxPAc should be 522.0 and fac 50.0 if they are float or 522i and 50i if they are int, try appending an i if those numbers are integers.

This is not the case as you suspected.
The numbers of the type float without decimal places, are also displayed without decimal places.

e.g. 50.00 will be displayed as 50

All values are of datatype float.
e.g.
The value for Fac has changed and I see now e.g. Fac: 50.01

Output

This is the function with which I create the value Fac:

Funktion

// Frequenz
var F_AC = parseFloat(msg.payload);
flow.set('F_AC', F_AC);
node.status({fill:"blue",shape:"ring",text: F_AC });
return;

The value for Fac has changed.

Import this in your node red, it is just a plain object that works writting values on Influx Out node.
based on the previous information I don’t see anything wrong with your object, maybe you had an older version of something?

dont forget to change your output node settings! (Bucket, Metric, IP, Token)

[{"id":"803d82f.ff80f8","type":"inject","z":"acb2ba8c.8edfa8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":80,"wires":[["9d6d6245.3950d"]]},{"id":"b75b04a0.a64048","type":"influxdb out","z":"acb2ba8c.8edfa8","influxdb":"eeb221fb.ab27f","name":"dataset1","measurement":"testing","precision":"","retentionPolicy":"","database":"database","precisionV18FluxV20":"ms","retentionPolicyV18Flux":"","org":"WD","bucket":"test","x":580,"y":80,"wires":[]},{"id":"f25f817b.a917","type":"debug","z":"acb2ba8c.8edfa8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":590,"y":120,"wires":[]},{"id":"9d6d6245.3950d","type":"template","z":"acb2ba8c.8edfa8","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\"SumE\": 186.842,\"TagE\": 3241,\"Pac\": 158.8,\"maxPac\": 522,\"Pdc\": 166.8,\"maxPdc\": 548.3,\"Temp\": 36.6,\"Uac\": 225.5,\"Fac\": 50.01}","output":"json","x":280,"y":80,"wires":[["f25f817b.a917","b75b04a0.a64048"]]},{"id":"eeb221fb.ab27f","type":"influxdb","hostname":"127.0.0.1","port":"8086","protocol":"http","database":"test","name":"test","usetls":true,"tls":"d50d0c9f.31e858","influxdbVersion":"2.0","url":"http://10.1.50.160:8086","rejectUnauthorized":true},{"id":"d50d0c9f.31e858","type":"tls-config","name":"","cert":"","key":"","ca":"","certname":"","keyname":"","caname":"","servername":"","verifyservercert":false}]

this is the plain object as simple as it can be, if this doesn’t work on your end, probably there is something else wrong

{“SumE”: 186.842,“TagE”: 3241,“Pac”: 158.8,“maxPac”: 522,“Pdc”: 166.8,“maxPdc”: 548.3,“Temp”: 36.6,“Uac”: 225.5,“Fac”: 50.01}

image

First of all thanks for your help.
I imported the whole thing and see that you are using a server [v2.0] in the node “influxdb out”.
I have been using a server as version [V1.x].
With the version [v2.0] I have the problem how to configure it.
Sorry, I’ll have to read up on that.
I will get back to you.

I think that maybe that is the issue

influxdb out

A simple influxdb output node to write values and tags to an influxdb measurement.

The fields and tags to write are in msg.payload. If msg.payload is a string, number, or boolean, it will be written as a single value to the specified measurement (called value).

If msg.payload is an object containing multiple properties, the fields will be written to the measurement.

If msg.payload is an array containing two objects, the first object will be written as the set of named fields, the second is the set of named tags.

Finally, if msg.payload is an array of arrays, it will be written as a series of points containing fields and tags.

If the measurement field is not set in the node configuration, the user can send in data with a specified measurement name in msg.measurement to overwrite the measurement field in the configuration of the node.

InfluxDB 1.x Mode

Check Advanced Query Options to specify a time precision and retention policy for the insertion.

The advanced query options Time Precision and Retention Policy can be overwritten using message properties msg.precision and msg.retentionPolicy.

InfluxDB 1.8 Flux and InfluxDB 2.0 Mode

If no retention policy is specified, autogen will be assumed.

according to this InfluxDB1.8 should be using 2.0 server configuration mode in the output node.

hello,

is there a way to send a txt or csv file to influxdb via node-red?

lg