# "Failed to parse JSON string"

**URL:** <https://discourse.nodered.org/t/failed-to-parse-json-string/31590>\
**Category:** General\
**Created:** [15 August 2020 18:39 UTC](https://discourse.nodered.org/t/failed-to-parse-json-string/31590 "2020-08-15T18:39:44Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zerg](https://avatars.discourse-cdn.com/v4/letter/z/6de8d8/32.png) [@Zerg](https://discourse.nodered.org/u/Zerg)\
**Post date:** [15 August 2020 18:39 UTC](https://discourse.nodered.org/t/failed-to-parse-json-string/31590/1 "2020-08-15T18:39:44Z")

</div>

I am trying to repeat the steps from this instruction: [https://flows.nodered.org/flow/b50779ea99f3daf38acc1ee6bed16c5b](https://flows.nodered.org/flow/b50779ea99f3daf38acc1ee6bed16c5b)  
But, I get errors all the time: " **Failed to parse JSON string**"

I installed "zigbee2mqtt" on "Ubuntu 20.04" following this instruction. [https://www.zigbee2mqtt.io/getting\_started/running\_zigbee2mqtt.html](https://www.zigbee2mqtt.io/getting_started/running_zigbee2mqtt.html)  
Node-Red I installed following this instruction [https://nodered.org/docs/getting-started/local](https://nodered.org/docs/getting-started/local)  
Everything was established normally.

my configuration.yaml

```auto
homeassistant: false
permit_join: false
advanced:
  channel: 26
  soft_reset_timeout: 3000
  log_level: debug
  report: true
mqtt:
  base_topic: zigbee2mqtt
  server: 'mqtt://192.168.18.101:1883'
serial:
  port: /dev/ttyACM0
  disable_led: false
experimental:
  livolo: true
devices:
  '0x680ae2fffe2ec6fd':
    friendly_name: '0x680ae2fffe2ec6fd'
  '0xccccccfffea4972a':
    friendly_name: '0xccccccfffea4972a'
  '0x588e81fffe4d159b':
    friendly_name: '0x588e81fffe4d159b'
  '0x588e81fffe36a343':
    friendly_name: '0x588e81fffe36a343'
  '0x000b3cfffef7c423':
    friendly_name: '0x000b3cfffef7c423'

```

The screenshot shows that the connection to "MQTT" is successful [https://ibb.co/fGjw9YC](https://ibb.co/fGjw9YC)  
But I don't understand why the data is not parsed! ☹

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [15 August 2020 19:18 UTC](https://discourse.nodered.org/t/failed-to-parse-json-string/31590/2 "2020-08-15T19:18:26Z")

</div>

FYI, in configuration.yaml, change the "friendly\_name"'s to something that is "friendly", then you will receive the friendly names in node-red (restart zigbee2mqtt once done), you don't have to parse the yaml file.

First connect a debug node to the zigbee mqtt node, set the output to "complete msg object" and post the output here. The reason why you get the "Failed to parse JSON string" errors is because the debug node is set to display the msg.payload. The mqtt node however, outputs strings of data, hence the error.

---

<div class="post-metadata">

**Author:** ![Zerg](https://avatars.discourse-cdn.com/v4/letter/z/6de8d8/32.png) [@Zerg](https://discourse.nodered.org/u/Zerg)\
**Post date:** [15 August 2020 19:55 UTC](https://discourse.nodered.org/t/failed-to-parse-json-string/31590/3 "2020-08-15T19:55:59Z")

</div>

I will change the "friendly\_name" later. Or it is important?

I did as you said and made a screen. Only the coordinator is seen.  
the screen: [https://ibb.co/SNLTtzW](https://ibb.co/SNLTtzW)

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [15 August 2020 20:12 UTC](https://discourse.nodered.org/t/failed-to-parse-json-string/31590/4 "2020-08-15T20:12:37Z")

</div>

> I will change the "friendly\_name" later. Or it is important?

Well you are creating a flow that reads the yaml file to translate the names, which is unnecessary.

What topic are you subscribed to ?  
Use `zigbee2mqtt/#` and you might have to wait for your devices to emit data.

---

<div class="post-metadata">

**Author:** ![Zerg](https://avatars.discourse-cdn.com/v4/letter/z/6de8d8/32.png) [@Zerg](https://discourse.nodered.org/u/Zerg)\
**Post date:** [15 August 2020 20:18 UTC](https://discourse.nodered.org/t/failed-to-parse-json-string/31590/5 "2020-08-15T20:18:35Z")

</div>

Yes, I am subscribed to "zigbee2mqtt/#"  
I have been in this state for a long time and nothing changes!  
screen: [https://ibb.co/FW8gMgj](https://ibb.co/FW8gMgj)

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [15 August 2020 20:21 UTC](https://discourse.nodered.org/t/failed-to-parse-json-string/31590/6 "2020-08-15T20:21:19Z")

</div>

set the mqtt node output to autodetect.

note that you can drag screenshots in edit window directly.

---

<div class="post-metadata">

**Author:** ![Zerg](https://avatars.discourse-cdn.com/v4/letter/z/6de8d8/32.png) [@Zerg](https://discourse.nodered.org/u/Zerg)\
**Post date:** [15 August 2020 20:30 UTC](https://discourse.nodered.org/t/failed-to-parse-json-string/31590/7 "2020-08-15T20:30:28Z")

</div>

It started working! now I think need just wait for when all the devices to start displayed!  
THANK YOU!!!

 ![75](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/e/be73f0afc3ada7ac778ede3a608a4317bc67d20d.png)  
 ![76](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/0/900ae3aa495215f3e1366b4d41d16a9c07766f63.png)

---

<div class="post-metadata">

**Author:** ![Zerg](https://avatars.discourse-cdn.com/v4/letter/z/6de8d8/32.png) [@Zerg](https://discourse.nodered.org/u/Zerg)\
**Post date:** [16 August 2020 11:38 UTC](https://discourse.nodered.org/t/failed-to-parse-json-string/31590/8 "2020-08-16T11:38:55Z")

</div>

It worked yesterday! And today it's writes an error: "TypeError: Cannot read property 'length' of undefined"  
I just in configuration.yaml, changed the "friendly\_name" and rebooted.  
my "new" configuration.yaml

```auto
homeassistant: false
permit_join: false
advanced:
  channel: 26
  soft_reset_timeout: 3000
  log_level: debug
  report: true
mqtt:
  base_topic: zigbee2mqtt
  server: 'mqtt://192.168.18.101:1883'
serial:
  port: /dev/ttyACM0
  disable_led: false
experimental:
  livolo: true
devices:
  '0x680ae2fffe2ec6fd':
    friendly_name: dimmer_round
  '0xccccccfffea4972a':
    friendly_name: dimmer_quadratic
  '0x588e81fffe4d159b':
    friendly_name: motion_sensor
  '0x588e81fffe36a343':
    friendly_name: color_lamp
  '0x000b3cfffef7c423':
    friendly_name: wall_socket

```

 ![987](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/c/fc03cc40469d80a65c30e5adb29f83f39b138e28.png)

my code: [https://pastebin.com/fxS5dZ82](https://pastebin.com/fxS5dZ82)

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [16 August 2020 13:01 UTC](https://discourse.nodered.org/t/failed-to-parse-json-string/31590/9 "2020-08-16T13:01:09Z")

</div>

The friendly name should be a string “blabla”.

The error comes from the “update chart” node.

---

<div class="post-metadata">

**Author:** ![Zerg](https://avatars.discourse-cdn.com/v4/letter/z/6de8d8/32.png) [@Zerg](https://discourse.nodered.org/u/Zerg)\
**Post date:** [16 August 2020 14:45 UTC](https://discourse.nodered.org/t/failed-to-parse-json-string/31590/10 "2020-08-16T14:45:52Z")

</div>

Thanks for the answer! I will keep in mind for the next time then I will rename my devices.  
now I returned to yesterday's value i.e. to the original default name.  
And still doesn't work!

And yes i see that the error comes from the “update chart” node. But, this knowledge does not help me!

now my configuration.yaml

```auto
homeassistant: false
permit_join: false
advanced:
  channel: 26
  soft_reset_timeout: 3000
  log_level: debug
  report: true
mqtt:
  base_topic: zigbee2mqtt
  server: 'mqtt://192.168.18.101:1883'
serial:
  port: /dev/ttyACM0
  disable_led: false
experimental:
  livolo: true
devices:
  '0x680ae2fffe2ec6fd':
    friendly_name: '0x680ae2fffe2ec6fd'
  '0xccccccfffea4972a':
    friendly_name: '0xccccccfffea4972a'
  '0x588e81fffe4d159b':
    friendly_name: '0x588e81fffe4d159b'
  '0x588e81fffe36a343':
    friendly_name: '0x588e81fffe36a343'
  '0x000b3cfffef7c423':
    friendly_name: '0x000b3cfffef7c423'

```

 ![8989](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/c/8c69ba25b6c91c7a28f8e484f714517bc2c635d0.png)

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [16 August 2020 15:30 UTC](https://discourse.nodered.org/t/failed-to-parse-json-string/31590/11 "2020-08-16T15:30:57Z")

</div>

> [@Zerg](#):
>
> And yes i see that the error comes from the “update chart” node. But, this knowledge does not help me!

You post your flow (as a screenshot). I point out where the error comes from, how can it not help you ?

Who created the flow ?

---

<div class="post-metadata">

**Author:** ![Zerg](https://avatars.discourse-cdn.com/v4/letter/z/6de8d8/32.png) [@Zerg](https://discourse.nodered.org/u/Zerg)\
**Post date:** [16 August 2020 17:09 UTC](https://discourse.nodered.org/t/failed-to-parse-json-string/31590/12 "2020-08-16T17:09:16Z")

</div>

sorry!  
I do not understand why the node "update chart" don't get data of the battery.  
my code of flow: [https://pastebin.com/t1zgvsrd](https://pastebin.com/t1zgvsrd)  
I am beginer in "Node-Red" and I trying to repeat the steps from this instruction: [https://flows.nodered.org/flow/b50779ea99f3daf38acc1ee6bed16c5b](https://flows.nodered.org/flow/b50779ea99f3daf38acc1ee6bed16c5b)

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [16 August 2020 17:32 UTC](https://discourse.nodered.org/t/failed-to-parse-json-string/31590/13 "2020-08-16T17:32:29Z")

</div>

That flow seems to be setup in an odd way.  
I would delete all nodes and start from scratch to start learning node-red.

Start with the mqtt node and a debug node, determine the data you receive and after that, [watch all the videos in this playlist](https://www.youtube.com/watch?v=ksGeUD26Mw0&list=PLyNBB9VCLmo1hyO-4fIZ08gqFcXBkHy-6) to get an understanding of node-red and how it works.

---

<div class="post-metadata">

**Author:** ![Zerg](https://avatars.discourse-cdn.com/v4/letter/z/6de8d8/32.png) [@Zerg](https://discourse.nodered.org/u/Zerg)\
**Post date:** [16 August 2020 17:34 UTC](https://discourse.nodered.org/t/failed-to-parse-json-string/31590/14 "2020-08-16T17:34:53Z")

</div>

ok, thank you!

---

<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:** [30 August 2020 17:34 UTC](https://discourse.nodered.org/t/failed-to-parse-json-string/31590/15 "2020-08-30T17:34:56Z")

</div>

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