0

Json parsing error - Missing token (Shelly Plus Plug S / MQTT)

netit 1 year ago in Devices / Other 0

Hello,

I sucessfully integrated a Shelly Plus Plug S via MQTT.

MQTT messages that contain "switch" updates (when it's turned on/off) are successfully interpreted. I catch them with Token Name : params.switch:0.output (see screenshot below).

Meanwhile, the Shelly device is also sending other MQTT messages with energy consumption information. When doing so, the parameter "output" is not present in the JSON file, resulting in a Exception error : Error parsing received data. Value cannot be null.Parameter name: value


Any advise how to prevent these errors ?

Thank you.

---

JSON message when "output" changes. This gets successfully parsed. Example of a switch off message :

{"src":"shellyplusplugs-e465b85ccccc","dst":"shellyplusplugs-e465b85ccccc/events","method":"NotifyStatus","params":{"ts":1701336805.47,"switch:0":{"id":0,"apower":0,"current":0,"output":false,"source":"WS_in","voltage":0}}}


Periodically JSON message to notify energy updates. These don't get successfully parsed (as it is missing the 'output' parameter. Example :


{"src":"shellyplusplugs-e465b85ccccc","dst":"shellyplusplugs-mytext/events","method":"NotifyStatus","params":{"ts":1701352440.40,"switch:0":{"id":0,"aenergy":{"by_minute":[5.012,8.202,0.000],"minute_ts":1701352439,"total":4.922}}}}

Image 4751

Image 4749