mirror of
https://github.com/Andre0512/pyhOn.git
synced 2025-05-13 22:54:26 -04:00
Fix connection issues
This commit is contained in:
parent
00ac6912e2
commit
79a121263f
5 changed files with 11 additions and 6 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue