Skip to content

Commit

Permalink
add timezone to PetKitClient
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertD502 authored Sep 23, 2023
1 parent 9def57c commit 2423ac6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions custom_components/petkit/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,19 @@
from .const import LOGGER, PETKIT_ERRORS, TIMEOUT


async def async_validate_api(hass: HomeAssistant, email: str, password: str, region: str) -> bool:
async def async_validate_api(hass: HomeAssistant, email: str, password: str, region: str, timezone: str) -> bool:
"""Get data from API."""

if timezone == "Set Automatically":
tz = None
else:
tz = timezone
client = PetKitClient(
email,
password,
session=async_get_clientsession(hass),
region=region,
timezone=tz,
timeout=TIMEOUT,
)
try:
Expand All @@ -30,7 +35,7 @@ async def async_validate_api(hass: HomeAssistant, email: str, password: str, reg
LOGGER.error(f'Could not authenticate on PetKit servers: {err}')
raise AuthError(err)
except TimezoneError:
error = 'A timezone could not be found. If you are running Home Assistant as a standalone Docker container, you must define the TZ environmental variable.'
error = 'A timezone could not be found. If you are running Home Assistant as a standalone Docker container, you must define the TZ environmental variable. If the TZ variable is defined or you are running Home Assistant OS, your timezone was not found in the tzlocal library - Please manually select a timezone during setup.'
LOGGER.error(f'{error}')
raise TimezoneError(error)
except ServerError as err:
Expand Down

0 comments on commit 2423ac6

Please sign in to comment.