# Node-red influxdb invalid boolean

**URL:** <https://discourse.nodered.org/t/node-red-influxdb-invalid-boolean/8059>\
**Category:** General\
**Created:** [17 February 2019 02:06 UTC](https://discourse.nodered.org/t/node-red-influxdb-invalid-boolean/8059 "2019-02-17T02:06:43Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Findre](https://avatars.discourse-cdn.com/v4/letter/f/e19b73/32.png) [@Findre](https://discourse.nodered.org/u/Findre)\
**Post date:** [17 February 2019 02:06 UTC](https://discourse.nodered.org/t/node-red-influxdb-invalid-boolean/8059/1 "2019-02-17T02:06:43Z")

</div>

Hello guys, I'm new to node-red and influxdb and mqtt so bear with me. So I'm trying to send a Json object to an influxdb database I created but when I try to send the object to influxdb I get the following error:

`Error: A 400 Bad Request error occurred: {"error":"unable to parse 'sonoff ENERGY=[object Object],Time=\"2019-02-16T19:51:25\"': invalid boolean"}`

The json string I get from the sensor is this:

`"{"Time":"2019-02-16T19:51:25","ENERGY":{"TotalStartTime":"2019-02-11T17:34:56","Total":1.507,"Yesterday":0.348,"Today":1.159,"Period":6,"Power":66,"ApparentPower":67,"ReactivePower":0,"Factor":0.99,"Voltage":126,"Current":0.532}}"`

Finally, the flow I am using is the following flow:

```auto
[{"id":"6ce293e0.d07ab4","type":"mqtt in","z":"31324429.f7d1ac","name":"","topic":"stat/sonoff/POWER","qos":"2","broker":"b219fa03.3781f8","x":279,"y":129,"wires":[["c6f3034f.ebd078"]]},{"id":"c6f3034f.ebd078","type":"debug","z":"31324429.f7d1ac","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":714,"y":102,"wires":[]},{"id":"b35ffdb9.9eb05","type":"mqtt in","z":"31324429.f7d1ac","name":"","topic":"tele/sonoff/SENSOR","qos":"2","broker":"b219fa03.3781f8","x":282,"y":215,"wires":[["ea18aa60.babca"]]},{"id":"ea18aa60.babca","type":"json","z":"31324429.f7d1ac","name":"","property":"payload","action":"","pretty":true,"x":531.5,"y":213,"wires":[["c6f3034f.ebd078","de651a0c.c782f"]]},{"id":"de651a0c.c782f","type":"influxdb out","z":"31324429.f7d1ac","influxdb":"de82086b.a7424","name":"measurements","measurement":"sonoff","precision":"","retentionPolicy":"","x":792.5,"y":218,"wires":[]},{"id":"b219fa03.3781f8","type":"mqtt-broker","z":"","name":"TESIS","broker":"192.168.2.3","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"de82086b.a7424","type":"influxdb","z":"","hostname":"192.168.2.3","port":"8086","protocol":"http","database":"Tesis","name":"TESIS","usetls":false,"tls":""}]

```

Everything together along with the error message looks something like this

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

I copied the flow from a video I saw on youtube and it works for his sensor, unfortunately it doesn't work for mine even tho we have the same sensor. I don't know if I'm doing something wrong and I can't seem to find the problem.

---

<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:** [17 February 2019 07:49 UTC](https://discourse.nodered.org/t/node-red-influxdb-invalid-boolean/8059/2 "2019-02-17T07:49:22Z")

</div>

Firstly, your flow is not importable, please see the link below for how to format it correctly. You can edit your previous post to fix it.  
However it seems from the image that the data you are sending to the influx node is not in the right format. If you look at the Info tab for that node it tells you the expected formats. What tags/fields are you wanting to write the data to? As you have it, it is trying to write the whole ENERGY object to one field.

> [@How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506):
>
> To share code samples or flow json in this forum, you need to take care to format it properly so that it is displayed correctly. The easiest way to do that is to click the 'Preformatted Text' button in the toolbar: [image] Then paste in your code or flow json. You should end up with three back-tick characters - ``` - on their own line before and after the code. On standard US English keyboards, this is on the same key as the ~ character. Using the backticks will ens…

---

<div class="post-metadata">

**Author:** ![Findre](https://avatars.discourse-cdn.com/v4/letter/f/e19b73/32.png) [@Findre](https://discourse.nodered.org/u/Findre)\
**Post date:** [3 March 2019 20:00 UTC](https://discourse.nodered.org/t/node-red-influxdb-invalid-boolean/8059/3 "2019-03-03T20:00:30Z")

</div>

I've edited the post as you mentioned, I'm not trying to write the whole ENERGY object to one field. I want everything in the ENERGY object to be written in the database and have each measurement (TotalStartTime, Total, Yesterday, etc) in different tags.

---

<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:** [3 March 2019 20:21 UTC](https://discourse.nodered.org/t/node-red-influxdb-invalid-boolean/8059/4 "2019-03-03T20:21:20Z")

</div>

Look at the info tab for the influx node and it tells you how to format the data. You have to split them out of the ENERGY object.

---

<div class="post-metadata">

**Author:** ![Findre](https://avatars.discourse-cdn.com/v4/letter/f/e19b73/32.png) [@Findre](https://discourse.nodered.org/u/Findre)\
**Post date:** [3 March 2019 20:51 UTC](https://discourse.nodered.org/t/node-red-influxdb-invalid-boolean/8059/5 "2019-03-03T20:51:16Z")

</div>

Thank for the advice, I've managed to edit the payload and successfully store it in influxdb.

---

<div class="post-metadata">

**Author:** ![gilbert](https://avatars.discourse-cdn.com/v4/letter/g/dec6dc/32.png) [@gilbert](https://discourse.nodered.org/u/gilbert)\
**Post date:** [11 April 2019 18:18 UTC](https://discourse.nodered.org/t/node-red-influxdb-invalid-boolean/8059/6 "2019-04-11T18:18:11Z")

</div>

Hi. I have the same problem, could you tell me how?

---

<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:** [11 April 2019 19:11 UTC](https://discourse.nodered.org/t/node-red-influxdb-invalid-boolean/8059/7 "2019-04-11T19:11:34Z")

</div>

How to do what?

---

<div class="post-metadata">

**Author:** ![vj\_v1](https://avatars.discourse-cdn.com/v4/letter/v/e19b73/32.png) [@vj\_v1](https://discourse.nodered.org/u/vj_v1)\
**Post date:** [11 April 2019 20:34 UTC](https://discourse.nodered.org/t/node-red-influxdb-invalid-boolean/8059/8 "2019-04-11T20:34:16Z")

</div>

> [@Findre](#):
>
> I've managed to edit the payload and successfully

Can you help with how to edit the payload to make this work?

---

<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:** [11 April 2019 21:02 UTC](https://discourse.nodered.org/t/node-red-influxdb-invalid-boolean/8059/9 "2019-04-11T21:02:35Z")

</div>

This section of the docs has information on messages and how to manipulate the contents.  
[https://nodered.org/docs/user-guide/messages](https://nodered.org/docs/user-guide/messages)

---

<div class="post-metadata">

**Author:** ![vj\_v1](https://avatars.discourse-cdn.com/v4/letter/v/e19b73/32.png) [@vj\_v1](https://discourse.nodered.org/u/vj_v1)\
**Post date:** [14 April 2019 03:38 UTC](https://discourse.nodered.org/t/node-red-influxdb-invalid-boolean/8059/10 "2019-04-14T03:38:41Z")

</div>

Thanks, that was helpful

---

<div class="post-metadata">

**Author:** ![f1shC0d3](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/f1shc0d3/32/20758_2.png) [@f1shC0d3](https://discourse.nodered.org/u/f1shC0d3)\
**Post date:** [27 April 2020 17:09 UTC](https://discourse.nodered.org/t/node-red-influxdb-invalid-boolean/8059/11 "2020-04-27T17:09:33Z")

</div>

Hi,

I'm new to node-red and influxdb, I have a zigbee sensor storing info in an influxdb and displaying in a grafana chart. Everything is working as expected but I'm getting the following error for each component that I storing in the influxDB:

Error: A 400 Bad Request error occurred: {"error":"unable to parse 'HumDespacho value=undefined': invalid boolean"}

I'm sending the data as a number and it's stored as float.

Could you help me?

This is the flow I'm using:

```auto
[{"id":"5f9c6c16.8ff774","type":"ui_gauge","z":"320a2d6e.4e6b22","name":"Temperatura Despacho Dashboard","group":"4a8a673d.b424a8","order":2,"width":4,"height":4,"gtype":"compass","title":"Temperatura","label":"º C","format":"{{value}} ","min":"16","max":"40","colors":["#00b500","#e6e600","#ca3838"],"seg1":"24","seg2":"27","x":800,"y":160,"wires":[]},{"id":"139f2101.baa01f","type":"ui_gauge","z":"320a2d6e.4e6b22","name":"Humedad Despacho Dashboard","group":"4a8a673d.b424a8","order":3,"width":4,"height":4,"gtype":"compass","title":"Humedad","label":"%","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"55","seg2":"70","x":790,"y":232,"wires":[]},{"id":"f1921d7b.315ab","type":"ui_text","z":"320a2d6e.4e6b22","group":"4a8a673d.b424a8","order":4,"width":0,"height":0,"name":"Presión Atmosférica Dashboard","label":"Presión Atmosférica","format":"{{msg.payload}}","layout":"col-center","x":790,"y":306,"wires":[]},{"id":"ebd5330d.fa2db","type":"zigbee-converter","z":"320a2d6e.4e6b22","shepherd":"16638dd0.3a1df2","name":"Despacho","topic":"zigbee/${name}","settopic":"zigbee/${name}/set","gettopic":"zigbee/${name}/get","device":"0x00158d00034d1564","attribute":"","payload":"json","x":250,"y":220,"wires":[["9c6e97a8.aeaaf8"]]},{"id":"3d566369.80c01c","type":"debug","z":"320a2d6e.4e6b22","name":"Link Quality","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":730,"y":340,"wires":[]},{"id":"9c6e97a8.aeaaf8","type":"function","z":"320a2d6e.4e6b22","name":"Función","func":"var msg1 = { payload:msg.payload.battery };\nvar msg2 = { payload:msg.payload.voltage };\nvar msg3 = { payload:msg.payload.temperature };\nvar msg4 = { payload:msg.payload.humidity};\nvar msg5 = { payload:msg.payload.pressure};\nvar msg6 = { payload:msg.payload.linkquality};\n\n\nreturn [msg1, msg2, msg3, msg4, msg5, msg6];","outputs":6,"noerr":0,"x":420,"y":220,"wires":[["59d7df81.23d47"],["7e48d54b.3a2ebc"],["5f9c6c16.8ff774","81f94e3b.fc6788"],["139f2101.baa01f","1640bd24.00247b"],["f1921d7b.315ab"],["3d566369.80c01c"]],"outputLabels":["% Batería","V Batería","Temperatura","Humedad","Presión Atmosférica",""]},{"id":"7e48d54b.3a2ebc","type":"ui_text","z":"320a2d6e.4e6b22","group":"4a8a673d.b424a8","order":6,"width":0,"height":0,"name":"Voltaje Batería Sensor Dashboard","label":"Voltaje Batería ","format":"{{value | number:0}} V","layout":"row-spread","x":800,"y":120,"wires":[]},{"id":"ea0ff1e7.43d8e","type":"comment","z":"320a2d6e.4e6b22","name":"Sensor Aqara Despacho","info":"","x":470,"y":100,"wires":[]},{"id":"81f94e3b.fc6788","type":"influxdb out","z":"320a2d6e.4e6b22","influxdb":"911d5296.4c4c08","name":"TempDespacho","measurement":"TempDespacho","precision":"","retentionPolicy":"","x":740,"y":196,"wires":[]},{"id":"1640bd24.00247b","type":"influxdb out","z":"320a2d6e.4e6b22","influxdb":"6427c6ae.c3c0d8","name":"HumDespacho","measurement":"HumDespacho","precision":"","retentionPolicy":"","x":740,"y":269,"wires":[]},{"id":"59d7df81.23d47","type":"influxdb out","z":"320a2d6e.4e6b22","influxdb":"972ba4d3.b96c38","name":"BatLevelDespacho","measurement":"BatLevelDespacho","precision":"","retentionPolicy":"","x":750,"y":80,"wires":[]},{"id":"4a8a673d.b424a8","type":"ui_group","z":"","name":"Sensores","tab":"67818b5d.842374","order":1,"disp":true,"width":"8","collapse":false},{"id":"16638dd0.3a1df2","type":"zigbee-shepherd","z":"","name":"zigbee herdsman","path":"/dev/ttyACM0","baudRate":"115200","rtscts":true,"channelList":[11],"led":"disabled"},{"id":"911d5296.4c4c08","type":"influxdb","z":"","hostname":"127.0.0.1","port":"8086","protocol":"http","database":"temperature","name":"","usetls":false,"tls":""},{"id":"6427c6ae.c3c0d8","type":"influxdb","z":"","hostname":"127.0.0.1","port":"8086","protocol":"http","database":"humidity","name":"","usetls":false,"tls":""},{"id":"972ba4d3.b96c38","type":"influxdb","z":"","hostname":"127.0.0.1","port":"8086","protocol":"http","database":"batteryLevel","name":"","usetls":false,"tls":""},{"id":"67818b5d.842374","type":"ui_tab","z":"","name":"Despacho","icon":"airline_seat_recline_normal","order":2,"disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [27 April 2020 20:25 UTC](https://discourse.nodered.org/t/node-red-influxdb-invalid-boolean/8059/12 "2020-04-27T20:25:31Z")

</div>

Start off by putting a `catch` node connected to a `debug` node (set to display "Complete msg object' to isolate where the error is occurring.

Also when you find a thread is a year old, it is better to start a new thread.

---

<div class="post-metadata">

**Author:** ![f1shC0d3](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/f1shc0d3/32/20758_2.png) [@f1shC0d3](https://discourse.nodered.org/u/f1shC0d3)\
**Post date:** [28 April 2020 06:25 UTC](https://discourse.nodered.org/t/node-red-influxdb-invalid-boolean/8059/13 "2020-04-28T06:25:16Z")

</div>

I can open a new thread if it's better, just let me know.I've just thought it was better to continue with this because the error seems similar.

Thanks for the hint. This is what I get, it seems to be relate to the "influxdb out" node.

 ![influxdb_error1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/6/866ac3465624520ed0b326816283854b69cd11fc.jpeg)

 ![influxdb_error2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/6/866c4de410e1e7b90ea3a122a733567cef30ba12.jpeg)

As you can see the data is logging to influxdb and at some point start throwing this error in node-red. Looking at influxdb it seems to be OK

![influxdb1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/e/8ecc951723fe5840fb6fc588aec317449f75f89c.jpeg)

![influxdb2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/b/6b4df3f5bb28eaaa4ca275b88ff52114d3819241.jpeg)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [28 April 2020 08:39 UTC](https://discourse.nodered.org/t/node-red-influxdb-invalid-boolean/8059/14 "2020-04-28T08:39:49Z")

</div>

So if you look at the error yhrn look sat the debug msg three above it, you will see the same \_msgid

 ![Screen Shot 2020-04-28 at 4.29.39 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/e/bed4540ef064c8f231e45de2781857f31b830406.png)

notice that there is no payload? It would seem to me that the msg from your zigbee device doesn't always have all the data in it.

You should connect a `debug` node (set to display the 'Complete msg object') to the outout of the zigbee node to see what the data is.

---

<div class="post-metadata">

**Author:** ![f1shC0d3](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/f1shc0d3/32/20758_2.png) [@f1shC0d3](https://discourse.nodered.org/u/f1shC0d3)\
**Post date:** [28 April 2020 11:46 UTC](https://discourse.nodered.org/t/node-red-influxdb-invalid-boolean/8059/15 "2020-04-28T11:46:48Z")

</div>

You're right, following your indications I can see 4 messages and 2 errors.

 ![influxdb_error3](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/e/6e60a4c3c6311450caf77a7e9c7f6b86d17b7c89.jpeg)

Those errors are because there is no "humitidy" information I guess, so that make sense. Payload is different.

Correct Payload

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

Incorrect Payload

![influxdb_error4_bad](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/3/a3efb08ba9d90e53a910c8c98563275bfc4e3a34.jpeg)

What I don't understand is why I'm getting this error if in the function I'm routing only the "humidity" information. This is what the flow looks like:

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

And the function contains:

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

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [28 April 2020 12:41 UTC](https://discourse.nodered.org/t/node-red-influxdb-invalid-boolean/8059/16 "2020-04-28T12:41:02Z")

</div>

> [@f1shC0d3](#):
>
> What I don't understand is why I'm getting this error if in the function I'm routing only the "humidity" information.
> 
> ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/a/4a5519ec9f754db5dcdc011c0c40c0b720658917.png)

You are unconditionally sending ALL 6 messages.

Consider this

- a `msg` arrives at function & `msg.payload.humitity` is `undefined`
- you **WILL** send {payload: undefined} out of pin 4. Every time!

You should check before making the `msg` an actual object...

```auto
var msg1, msg2, msg3, msg4, msg5, msg6 //these will be empty/uninitialised variables
if(msg.payload.battery){
  msg1 = {payload: msg.payload.battery}
}
//..others...
if(msg.payload.humitity){
  msg4 = {payload: msg.payload.humitity}
}
//..etc...
return [msg1, msg2, msg3, msg4, msg5, msg6];

```

... the reason this will work is if `humitity` is null, you WONT turn `msg4` into an object (it will be `null`) - node-red doesnt fire an output if the item is null/undefined.

## PS: Please post code instead of screen shots - it is annoying to have to retype something to show you a solution

And please put code between thre back ticks  
`````  
`like this`  
`````

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [28 April 2020 12:47 UTC](https://discourse.nodered.org/t/node-red-influxdb-invalid-boolean/8059/17 "2020-04-28T12:47:13Z")

</div>

Two things right off. First, put a name in each of your `debug` nodes to make it easy to identify what messages in the log are from which `debug` node. Second, get rid of one of the `catch` nodes and connect the other to a stand alone `debug` node - you don't need two of them.

So it looks like the data coming in is sometimes is missing the battery, voltage, humidity and pressure data. That is something you will have to take up with the make of the device.

You could add a switch after each of the function nodes outputs and check if the data is defined and only pass it on if it is.

---

<div class="post-metadata">

**Author:** ![f1shC0d3](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/f1shc0d3/32/20758_2.png) [@f1shC0d3](https://discourse.nodered.org/u/f1shC0d3)\
**Post date:** [28 April 2020 16:27 UTC](https://discourse.nodered.org/t/node-red-influxdb-invalid-boolean/8059/18 "2020-04-28T16:27:51Z")

</div>

@Steve-Mcl, @zenofmud Following your indications finally I've managed to get it solve. 😃 Also I take some tips to debug and to post in the right way. Many thanks
