Different Datatypes in Node-RED

Hello guys!
I am working with Exec-Nodes and want that the data to be stored in InfluxDB afterwards. I am running a python script do measure Lux in the Exec-Node. There is a problem according different data-types (float and string).

Wiring:
grafik

Debug-Message:
grafik

Setting Exec-Node
grafik

Regards,
Jacob

Looks like you have written the value as a string at some time in the past and are now trying to write it as a float. Try deleting the measurement "Temp", and try again. You cannot mix types in a measurement field.

Okay yes, makes sense! I tried it again with a new "Temp" but the problem is still there.
Is there a way of changing the datatype (float -> string) straight with a node / a command in node-red?

You don't want to change it to a string, numbers should always be stored as numbers.
If you dropped the measurement but still get the problem then you must have written a string to it again, before writing the number.
I suggest doing select * from Temp and see what is there, that may give you a clue.
Otherwise drop the measurement again and do a select * from Temp to make sure it is empty. Then put a debug node showing everything you are writing to it. The first value you write must be a string.

Another thought. You could put a Switch node configured like this before the Influx node.

image

Feed output 1 to the Influx node and output 2 to a debug node. Then only numbers will get through to the database. Possibly there is some sort of error message or similar getting written first.

1 Like