New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSON-RPC Method SysVar.getAll returns invalid JSON #239
Comments
You probably know that |
Of course :) So the JSON-RPC request receives a response of MIME type application/json with a response body that contains JSON where the curly brackets have been escaped. I've confirmed with tcpdump that this is indeed in the raw response itself: The way this escaping works seems to be invalid in JSON, after a backslash only a hex-encoded number representing the unicode char or another backslash is legit. The backslash can be just dropped because curly brackets don't need to be escaped in JSON: JSON decoders in browsers are much more lenient than the python one, I could decode the sequence in chrome. So I assume that is the reason why the web interface can decode it - or they replace the string in the response before parsing the JSON. There is a small example code in this gist that uses pyhomematic to retrieve the list of devices and then the system variables, which should fail: Please let me know if you need more information. |
And I just realise that this is probably more an issue of OCCU than of RaspberryMatic? Sorry about that. |
This is no problem as RaspberryMatic is more or less the testbed for OCCU and will submit fixed back to upstream once they are found to be stable |
Can you please provide an example without pyhomematic where the http://XXXXX/api/homematic.cgi is used and returns invalid json? This would make debugging for me way easier. |
Sure, I've found a way to use curl from the shell. First we need the session token:
In this case the session token is vVU4HVJGWZ. Then get the variables:
All the backslashes in the response here are actually wrong. |
I think I found the origin where the https://github.com/eq-3/occu/blob/master/WebUI/www/api/eq3/json.tcl#L207-L208 If you comment out these two lines (the file on your CCU/RaspberryMatic is located at |
I just integrated a patch to fix this issue. Please test and report back if there are other issues appearing... |
Awesome, it fixes the issue with Home Assistant. A brief use of the raspimatic web ui shows no issues. |
I'm using raspberrymatic version 2.29.23.20171216 in conjunction with Home Assistant via pyhomematic. The module calls SysVar.getAll via JSON-RPC, which returns:
Decoding this throws an Exception from Pythons jsons.decode: Exception: Invalid \escape: line 1 column 58 (char 57)
Running this through jsonlint.com confirms that escaping the angled brackets (the {) is not allowed. As far as I understand in JSON backslashes are supposed to be followed by a hex utf8 sequence or another backslash.
I'm unsure if I can just delete these system variables to get it running again?
The text was updated successfully, but these errors were encountered: