Hi all,
I have a MQTT topic that seems to be storing a float as a string. Example:
It is a reading from a electricity consumption monitor and stores 33.2 or 45.3 in MQTT as a string. I have no control of how its doing this.
I have a simple flow in node red that does:
MQTT Electricity Topic > Influx (Measurement)
The issue is it creates a measurement with the following Field Keys:
Time , Value (as string)
I went into the Influx CLI and created my own measurement with Time, Value (Float) but of course (and I expected this) when I reroute the flow to that new measurement, I get the following error:
Error: A 400 Bad Request error occurred: {"error":"partial write: field type conflict: input field \"value\" on measurement \"B14023Device0Study\" is type string, already exists as type float dropped=1"
Which tells me of course that the flow is trying to pass a string value to a field key pairing that requires float.
My question
How I am thinking of it is that in the flow there is going to be a need for me to convert the value coming out of the MQTT topic as string to float, then pass that value to the influx db measurement I created with the field key pairing with the float.
So:
- Is my thinking correct
- What would be the easiest way to do this conversion of the string value out of the MQTT topic into a float before I pass it to the influx node to write into that measurement? From the research I found this article Convert I can pretty much make out how to convert it. Just want to check my thinking on point 1 first.
Would really appreciate the guidance.