Skip to content

Commit

Permalink
Merge pull request #88 from RobertD502/fix_device_query
Browse files Browse the repository at this point in the history
Fix device query to use renamed function
  • Loading branch information
RobertD502 authored Nov 4, 2024
2 parents e3a3975 + 13b215b commit f124257
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion custom_components/petkit/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
"petkitaio==0.1.11.2",
"tzlocal==5.1"
],
"version": "0.1.12.1"
"version": "0.1.12.2"
}
7 changes: 4 additions & 3 deletions custom_components/petkit/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async def async_validate_api(hass: HomeAssistant, email: str, password: str, reg
)
try:
async with async_timeout.timeout(TIMEOUT):
devices_query = await client.get_device_roster()
devices_query = await client.get_device_rosters()
except AuthError as err:
LOGGER.error(f'Could not authenticate on PetKit servers: {err}')
raise AuthError(err)
Expand All @@ -51,9 +51,10 @@ async def async_validate_api(hass: HomeAssistant, email: str, password: str, reg
LOGGER.error(f'Failed to get information from PetKit servers: {err}')
raise ConnectionError from err

devices: dict[str, Any] = devices_query['result']['devices']
devices = sum(len(value['result']['devices']) for value in devices_query.values())

if not devices:

if devices == 0:
LOGGER.error("Could not retrieve any devices from PetKit servers")
raise NoDevicesError
return True
Expand Down

0 comments on commit f124257

Please sign in to comment.