Skip to content
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

Non-printable characters in SSID can be returned by Wiser Heat Hub #17

Closed
TobyLL opened this issue Mar 27, 2020 · 0 comments · Fixed by #16
Closed

Non-printable characters in SSID can be returned by Wiser Heat Hub #17

TobyLL opened this issue Mar 27, 2020 · 0 comments · Fixed by #16

Comments

@TobyLL
Copy link
Contributor

TobyLL commented Mar 27, 2020

I have just installed wiserHomeAssistantPlatform - thank you very much for the work you have put into it. I did have one issue that stopped it from working, as follows:

After installation and configuration, it didn't seem that anything worked, as nothing appeared on the dashboard. Digging around in the logs returned this error:

2020-03-26 20:18:22 ERROR (MainThread) [homeassistant.setup] Error during setup of component wiser
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 170, in _async_setup_component
    hass, processed_config
  File "/config/custom_components/wiser/__init__.py", line 69, in async_setup
    data = WiserHubHandle(hass, config, host, secret)
  File "/config/custom_components/wiser/__init__.py", line 116, in __init__
    self.wiserhub = wiserHub(self.ip, self.secret)
  File "/usr/local/lib/python3.7/site-packages/wiserHeatingAPI/wiserHub.py", line 101, in __init__
    self.refreshData()  # Issue first refresh in init
  File "/usr/local/lib/python3.7/site-packages/wiserHeatingAPI/wiserHub.py", line 191, in refreshData
    self.hubIP), headers=self.headers, timeout=TIMEOUT).json()
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 890, in json
    self.content.decode(encoding), **kwargs
  File "/usr/local/lib/python3.7/site-packages/simplejson/__init__.py", line 525, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.7/site-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/local/lib/python3.7/site-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Invalid control character '\x18' at: line 1 column 1185 (char 1184)

After a bit of hacking to print out the actual body of the response, the following was appearing in the binary string returned by the Wiser Heat Hub:

{"SSID":"\r!","Channel":6,"SecurityMode":"WPA_WPA2_PSK","RSSI":-91},{"SSID":"\x13!","Channel":6,"SecurityMode":"WPA_WPA2_PSK","RSSI":-94}

and according to https://jsonlint.com this isn't valid JSON.

I have solved this on my local copy by taking the body of the response, removing non-printable characters, and then passing that to json.loads(). I'll raise a PR for that shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant