# JSON formatting from new Shelly Devices via. MQTT

**URL:** <https://discourse.nodered.org/t/json-formatting-from-new-shelly-devices-via-mqtt/62612>\
**Category:** General\
**Tags:** mqtt\
**Created:** [14 May 2022 05:56 UTC](https://discourse.nodered.org/t/json-formatting-from-new-shelly-devices-via-mqtt/62612 "2022-05-14T05:56:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nobbyneb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nobbyneb/32/61550_2.png) [@nobbyneb](https://discourse.nodered.org/u/nobbyneb)\
**Post date:** [14 May 2022 05:56 UTC](https://discourse.nodered.org/t/json-formatting-from-new-shelly-devices-via-mqtt/62612/1 "2022-05-14T05:56:06Z")

</div>

Hi everybody,

I'm new to Node-RED and having some difficulty reformatting JSON outputted from the new series of Shelly Plus devices via MQTT.

I am receiving messages from Shelly OK but Node-RED appears to be getting incorrectly formatted JSON.

I've copied the raw JSON below as it appears in the debug window (which appears fine to me?), but when I try to isolate the "apower" value using a set.apower, I get _undefined_ back. The screenshot from the debug window suggests to me that NR isn't recognising the JSON format properly but I'd be grateful advice while I learn these NR basics.

{"id":0, "source":"HTTP", "output":false, "apower":0.0, "voltage":229.1, "current":0.000, "aenergy":{"total":8338.817,"by\_minute":[0.000,0.000,0.000],"minute\_ts":1652445599},"temperature":{"tC":47.9, "tF":118.2}}

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

Many thanks.

---

<div class="post-metadata">

**Author:** ![greengolfer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/greengolfer/32/28276_2.png) [@greengolfer](https://discourse.nodered.org/u/greengolfer)\
**Post date:** [14 May 2022 06:15 UTC](https://discourse.nodered.org/t/json-formatting-from-new-shelly-devices-via-mqtt/62612/2 "2022-05-14T06:15:22Z")

</div>

MQTT node output is a string (as shown in the debug output). It is looking like JSON for a human but not to a computer 😉  
Stick a json node out of the MQTT node and then , out of that node you will get a real JSON.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [14 May 2022 06:21 UTC](https://discourse.nodered.org/t/json-formatting-from-new-shelly-devices-via-mqtt/62612/3 "2022-05-14T06:21:00Z")

</div>

You can also set the 'Output' on the MQTT-In node to be 'a parsed JSON object'.  
 ![Screen Shot 05-14-22 at 07.19 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/2/f251d6c39099a94b8ca57ff72becc10fe7d57aa9.png)

---

<div class="post-metadata">

**Author:** ![nobbyneb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nobbyneb/32/61550_2.png) [@nobbyneb](https://discourse.nodered.org/u/nobbyneb)\
**Post date:** [15 May 2022 21:18 UTC](https://discourse.nodered.org/t/json-formatting-from-new-shelly-devices-via-mqtt/62612/4 "2022-05-15T21:18:02Z")

</div>

Thanks so much, this worked perfectly. Really appreciate the help.

---

<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:** [14 July 2022 21:18 UTC](https://discourse.nodered.org/t/json-formatting-from-new-shelly-devices-via-mqtt/62612/5 "2022-07-14T21:18:43Z")

</div>

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