cyberjunky/home-assistant-toon_climate

decode issues - master branch and others

mvdbr4nd opened this issue · 1 comments

For some reason the JSON decode fails. I did a test in the same VENV as HA. as follows (which works fine):

The minetype issue does not occur in the following sample which is even stranger. Obviously I did the test in the same venv to prevent version issues.

`

url = "http://192.168.0.102:80/happ_thermstat?action=getThermostatInfo"

async def main():

 async with aiohttp.ClientSession() as session:

     async with session.get(url, headers={"Accept-Encoding": "identity"}) as resp:

         print(resp.status)

         response = await resp.json(content_type="text/javascript")

         print(response['currentTemp'])

loop = asyncio.get_event_loop()

loop.run_until_complete(main())

`

logs
2021-01-12 09:18:07 ERROR (MainThread) [homeassistant.components.climate] toon_climate: Error on device update!
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/entity_platform.py", line 359, in _async_add_entity
await entity.async_device_update(warning=False)
File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/entity.py", line 466, in async_device_update
await task
File "/home/homeassistant/.homeassistant/custom_components/toon_climate/climate.py", line 143, in async_update
self._data = await self.do_api_request(
File "/home/homeassistant/.homeassistant/custom_components/toon_climate/climate.py", line 128, in do_api_request
response = await response.json(content_type="text/javascript")
File "/srv/homeassistant/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 1099, in json
raise ContentTypeError(
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html', url=URL('http://192.168.102:80/happ_thermstat?action=getThermostatInfo')

Nevermind.. config issue with the BASE URL.