blakadder / nspanel

Sonoff NSPanel protocol and hacking information. Tasmota Berry driver for NSPanel
https://blakadder.github.io/nspanel/
Creative Commons Zero v1.0 Universal
129 stars 35 forks source link

Faulty payload of Widget 3 as scene #8

Open R1N4x opened 2 years ago

R1N4x commented 2 years ago

So I found a weird bug while testing widgets, especially scenes.

If I set the index 3 widget as a scene the MQTT output has an additional brace at the end breaking the parsing.

Console output:

23:28:57.903 NSP: Received Raw = bytes('55AA860A007B226964223A2233227D7DAF00') 23:28:57.915 bytes('7B226964223A2233227D7D') 23:28:57.931 MQT: tele/NSPanel/RESULT = {"NSPanel":{"id":"3"}}}

My quick and dirty workaround so far: R1N4x:widget-3-fix

blakadder commented 2 years ago

That's a second report of malformed JSON. Need to investigate whether its a bug in the NSPanel firmware or the drives is reading something incorrectly

martingrayson commented 2 years ago

I can also confirm widget 3 gives me some funky result when using a scene. I've been scratching my head for a few days, its good to see someone else has spotted the malformed payload!

yvesdm3000 commented 2 years ago

I think the parsing code in nspanel.be is wrong, the piece where it finds the end is done by searching for the '}' character, but if there is some additional data that also happens to be 0x125 (== curly close brace) then it points to the wrong data at the end of the payload.

yvesdm3000 commented 2 years ago

See https://github.com/blakadder/nspanel/pull/27

slime1982 commented 1 year ago

Was this ever fixed? I've just run into this exact problem with the extra } on 3. It's preventing my rule (triggered by NSPanel#id) from running when selecting 3.