mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 01:37:08 +00:00
Work around bad content-type in Hook api response (#7267)
This commit is contained in:
parent
0e662c4007
commit
64da8cd47d
@ -47,7 +47,9 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
data={
|
||||
'username': username,
|
||||
'password': password})
|
||||
data = yield from response.json()
|
||||
# The Hook API returns JSON but calls it 'text/html'. Setting
|
||||
# content_type=None disables aiohttp's content-type validation.
|
||||
data = yield from response.json(content_type=None)
|
||||
except (asyncio.TimeoutError, aiohttp.ClientError) as error:
|
||||
_LOGGER.error("Failed authentication API call: %s", error)
|
||||
return False
|
||||
@ -63,7 +65,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
response = yield from websession.get(
|
||||
'{}{}'.format(HOOK_ENDPOINT, 'device'),
|
||||
params={"token": token})
|
||||
data = yield from response.json()
|
||||
data = yield from response.json(content_type=None)
|
||||
except (asyncio.TimeoutError, aiohttp.ClientError) as error:
|
||||
_LOGGER.error("Failed getting devices: %s", error)
|
||||
return False
|
||||
@ -110,7 +112,7 @@ class HookSmartHome(SwitchDevice):
|
||||
with async_timeout.timeout(TIMEOUT, loop=self.hass.loop):
|
||||
response = yield from websession.get(
|
||||
url, params={"token": self._token})
|
||||
data = yield from response.json()
|
||||
data = yield from response.json(content_type=None)
|
||||
|
||||
except (asyncio.TimeoutError, aiohttp.ClientError) as error:
|
||||
_LOGGER.error("Failed setting state: %s", error)
|
||||
|
Loading…
x
Reference in New Issue
Block a user