Fix connection issues

This commit is contained in:
Andre Basche 2023-03-06 18:57:08 +01:00
parent 00ac6912e2
commit 79a121263f
5 changed files with 11 additions and 6 deletions

View file

@ -84,7 +84,7 @@ class HonConnection:
return {}
return result
async def load_attributes(self, device: HonDevice):
async def load_attributes(self, device: HonDevice, loop=False):
params = {
"macAddress": device.mac_address,
"applianceType": device.appliance_type_name,
@ -92,6 +92,10 @@ class HonConnection:
}
url = f"{const.API_URL}/commands/v1/context"
async with self._session.get(url, params=params, headers=await self._headers) as response:
if response.status_code >= 400 and not loop:
_LOGGER.error("%s - Error %s - %s", url, response.status_code, await response.text)
await self.setup()
return await self.load_attributes(device, loop=True)
return (await response.json()).get("payload", {})
async def load_statistics(self, device: HonDevice):