Skip to content

Commit

Permalink
use renamed function when device_query used during config flow
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertD502 authored Nov 4, 2024
1 parent e3a3975 commit 8533804
Showing 1 changed file with 4 additions and 3 deletions.
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 8533804

Please sign in to comment.