# Different Datatypes in Node-RED

**URL:** <https://discourse.nodered.org/t/different-datatypes-in-node-red/56216>\
**Category:** General\
**Created:** [6 January 2022 19:19 UTC](https://discourse.nodered.org/t/different-datatypes-in-node-red/56216 "2022-01-06T19:19:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jacob22](https://avatars.discourse-cdn.com/v4/letter/j/97f17d/32.png) [@jacob22](https://discourse.nodered.org/u/jacob22)\
**Post date:** [6 January 2022 19:19 UTC](https://discourse.nodered.org/t/different-datatypes-in-node-red/56216/1 "2022-01-06T19:19:56Z")

</div>

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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/9/c97c1cd790a704c76eede0e21c8d57f3e3ebfa50.png)

Debug-Message:  
 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/7/e739336683865007fc2c1f88d9e644eb432cd5e8.png)

Setting Exec-Node  
 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/f/bf1c6c7f5a9df373efee27af6dd46bd794104aec.png)

Regards,  
Jacob

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [6 January 2022 19:28 UTC](https://discourse.nodered.org/t/different-datatypes-in-node-red/56216/2 "2022-01-06T19:28:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jacob22](https://avatars.discourse-cdn.com/v4/letter/j/97f17d/32.png) [@jacob22](https://discourse.nodered.org/u/jacob22)\
**Post date:** [6 January 2022 20:29 UTC](https://discourse.nodered.org/t/different-datatypes-in-node-red/56216/3 "2022-01-06T20:29:56Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [6 January 2022 20:50 UTC](https://discourse.nodered.org/t/different-datatypes-in-node-red/56216/4 "2022-01-06T20:50:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [6 January 2022 21:05 UTC](https://discourse.nodered.org/t/different-datatypes-in-node-red/56216/5 "2022-01-06T21:05:45Z")

</div>

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

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/a/3a910829efa7921575fc27551df199236a90ad92.png)

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [7 March 2022 21:06 UTC](https://discourse.nodered.org/t/different-datatypes-in-node-red/56216/6 "2022-03-07T21:06:04Z")

</div>

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