# Unable to parse: invalid boolean

**URL:** <https://discourse.nodered.org/t/unable-to-parse-invalid-boolean/77447>\
**Category:** General\
**Created:** [11 April 2023 08:06 UTC](https://discourse.nodered.org/t/unable-to-parse-invalid-boolean/77447 "2023-04-11T08:06:35Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![MichaelRenner](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/michaelrenner/32/78730_2.png) [@MichaelRenner](https://discourse.nodered.org/u/MichaelRenner)\
**Post date:** [11 April 2023 08:06 UTC](https://discourse.nodered.org/t/unable-to-parse-invalid-boolean/77447/1 "2023-04-11T08:06:35Z")

</div>

Moin,

everything has worked so far, but now I have no idea.

Given: A thermometer sending data via wifi and mqtt. I want to display that in Grafana. Works fine with "mqtt in", my InfluxDB and Grafana. The data format (displayed with mosquitto):  
\*\*\*\*/\*\*\*\*\*/Garden/status/humidity:0 {"id":0,"rh":65.6}

The devices also send the voltage of the batteries, format (with mosquitto) is this:  
\*\*\*\*/\*\*\*\*\*/Garten/status/devicepower:0 {"id": 0,"battery":{"V":6.18, "percent":100},"external":{"present ":false}}

Unfortunately there is this error:

Error: A 400 Bad Request error occurred: {"error":"unable to parse 'SpannungGarten battery=[object Object],external=[object Object],id=0': invalid boolean"}

What to do?

---

<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 2023 09:30 UTC](https://discourse.nodered.org/t/unable-to-parse-invalid-boolean/77447/2 "2023-04-11T09:30:11Z")

</div>

Welcome to the forum @MichaelRenner

Is the error coming from an influxdb Out node? If you click on the node id above the error message it should take you to the relevant node. Even better, if you have named all your nodes then the name will appear in the debug pane.

If it is coming from an Influxdb Out node then the problem is that the payload you have shown is not valid for writing to influxdb. If you look at the help text for the node it tells you the valid payload formats. Influx cannot cope with structured data (objects within objects) it must only have fields and tags.

---

<div class="post-metadata">

**Author:** ![MichaelRenner](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/michaelrenner/32/78730_2.png) [@MichaelRenner](https://discourse.nodered.org/u/MichaelRenner)\
**Post date:** [13 April 2023 15:52 UTC](https://discourse.nodered.org/t/unable-to-parse-invalid-boolean/77447/3 "2023-04-13T15:52:49Z")

</div>

Moin Colin,

thanks for the friendly welcome.

you recognized the problem right away:

```auto
Influx cannot cope with structured data (objects within objects) it must only have fields and tags.

```

The problem is the battery object  
{  
"id": 0,  
"battery": {  
"V": 6.17,  
"percent": 100  
},  
"external": {  
"present": false  
}  
}

Is there a way to preprocess the data, e.g. by filtering just for the V (for voltage) object like I would do it using jq (jq .battery.V)? Or an other solution?

Thanks

---

<div class="post-metadata">

**Author:** ![mudwalker](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@mudwalker](https://discourse.nodered.org/u/mudwalker)\
**Post date:** [13 April 2023 16:38 UTC](https://discourse.nodered.org/t/unable-to-parse-invalid-boolean/77447/4 "2023-04-13T16:38:12Z")

</div>

Welcome @MichaelRenner

> [@MichaelRenner](#):
>
> "id": 0,"battery":{"V":6.18, "percent":100},"external":{"present ":false}}

Can you post the actual message actually sent the InfuxDB Input Node?

Add a Debug Node and then, from the right hand sidebar in the Debug Window enclose a copy of the complete message between `</>` so that we get an exact copy. We can then work on that.

---

<div class="post-metadata">

**Author:** ![MichaelRenner](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/michaelrenner/32/78730_2.png) [@MichaelRenner](https://discourse.nodered.org/u/MichaelRenner)\
**Post date:** [13 April 2023 17:13 UTC](https://discourse.nodered.org/t/unable-to-parse-invalid-boolean/77447/5 "2023-04-13T17:13:43Z")

</div>

Moin,

this is the message like the debug node showed it.

```auto
{"id":0,"battery":{"V":5.95,"percent":97},"external":{"present":false}}

```

Path is: payload

This is the error message:

```auto
Error: A 400 Bad Request error occurred: {"error":"unable to parse 'SpannungKeller battery=[object Object],external=[object Object],id=0': invalid boolean"}

```

Not sure if this is the content you asked for, so I made a screenshot. The node named "Maudach" is the influxdb out node.

![Screenshot_20230413_190559](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/d/6df28775553c6df58d0de5fccba8d1fb099fcf15.png)  
 ![Screenshot_20230413_190959](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/6/f6e80d243b6dd35f986f255ebeb434e8a345e80d.png)

I am just confused as you ask for influxdb in but it is the influxdb out node. This setup works for the temperatures and the humidity.

Does that give clues?

Micha

---

<div class="post-metadata">

**Author:** ![mudwalker](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@mudwalker](https://discourse.nodered.org/u/mudwalker)\
**Post date:** [13 April 2023 17:17 UTC](https://discourse.nodered.org/t/unable-to-parse-invalid-boolean/77447/6 "2023-04-13T17:17:13Z")

</div>

My bad!! Indeed InfluxDB out - I was looking at one of my own flows and confused myself!!

---

<div class="post-metadata">

**Author:** ![MichaelRenner](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/michaelrenner/32/78730_2.png) [@MichaelRenner](https://discourse.nodered.org/u/MichaelRenner)\
**Post date:** [13 April 2023 17:35 UTC](https://discourse.nodered.org/t/unable-to-parse-invalid-boolean/77447/7 "2023-04-13T17:35:49Z")

</div>

Good to hear, I thought I had set something up completely wrong 🙂

---

<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:** [13 April 2023 17:54 UTC](https://discourse.nodered.org/t/unable-to-parse-invalid-boolean/77447/8 "2023-04-13T17:54:21Z")

</div>

> [@MichaelRenner](#):
>
> Is there a way to preprocess the data, e.g. by filtering just for the V (for voltage) object like I would do it using jq (jq .battery.V)? Or an other solution?

Have a look at the node red docs Working with Messages. That should get you started.

If you are a beginner then I recommend watching this playlist: [Node-RED Essentials](https://www.youtube.com/playlist?list=PLyNBB9VCLmo1hyO-4fIZ08gqFcXBkHy-6). The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

---

<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:** [13 April 2023 20:07 UTC](https://discourse.nodered.org/t/unable-to-parse-invalid-boolean/77447/9 "2023-04-13T20:07:27Z")

</div>

Then read the help text for the influx node and work out what structure you want in msg.payload.

---

<div class="post-metadata">

**Author:** ![MichaelRenner](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/michaelrenner/32/78730_2.png) [@MichaelRenner](https://discourse.nodered.org/u/MichaelRenner)\
**Post date:** [6 May 2023 11:08 UTC](https://discourse.nodered.org/t/unable-to-parse-invalid-boolean/77447/10 "2023-05-06T11:08:32Z")

</div>

Moin,

I did so. At least understood enough to solve the problem. For the archive:  
Usung the function node

> msg.payload = { "volatage": msg.payload.battery.V }  
> return msg;

Thans for this hint.  
Micha

---

<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:** [5 July 2023 11:08 UTC](https://discourse.nodered.org/t/unable-to-parse-invalid-boolean/77447/11 "2023-07-05T11:08:54Z")

</div>

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