JSON formatting from new Shelly Devices via. MQTT

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}}

Many thanks.

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 :wink:
Stick a json node out of the MQTT node and then , out of that node you will get a real JSON.

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

3 Likes

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

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