diff --git a/custom_components/petkit/config_flow.py b/custom_components/petkit/config_flow.py index f7a6d91..3dc5756 100644 --- a/custom_components/petkit/config_flow.py +++ b/custom_components/petkit/config_flow.py @@ -4,7 +4,7 @@ from collections.abc import Mapping from typing import Any -from petkitaio.exceptions import AuthError, PetKitError, RegionError, ServerError +from petkitaio.exceptions import AuthError, PetKitError, RegionError, ServerError, TimezoneError import voluptuous as vol from homeassistant import config_entries @@ -67,6 +67,8 @@ async def async_step_reauth_confirm( await async_validate_api(self.hass, email, password, region) except RegionError: errors["base"] = "region_error" + except TimezoneError: + errors["base"] = "timezone_error" except AuthError: errors["base"] = "invalid_auth" except ConnectionError: @@ -118,6 +120,8 @@ async def async_step_user( await async_validate_api(self.hass, email, password, region) except RegionError: errors["base"] = "region_error" + except TimezoneError: + errors["base"] = "timezone_error" except AuthError: errors["base"] = "invalid_auth" except ConnectionError: diff --git a/custom_components/petkit/manifest.json b/custom_components/petkit/manifest.json index 00e78c2..10e786c 100644 --- a/custom_components/petkit/manifest.json +++ b/custom_components/petkit/manifest.json @@ -11,8 +11,8 @@ "iot_class": "cloud_polling", "issue_tracker": "https://github.com/RobertD502/home-assistant-petkit/issues", "requirements": [ - "petkitaio==0.1.8", + "petkitaio==0.1.9", "tzlocal>=4.2" ], - "version": "0.1.8" + "version": "0.1.9" } diff --git a/custom_components/petkit/strings.json b/custom_components/petkit/strings.json index e1babcf..60dab3f 100644 --- a/custom_components/petkit/strings.json +++ b/custom_components/petkit/strings.json @@ -26,7 +26,8 @@ "no_devices": "No devices found on account", "server_busy": "PetKit servers are busy. Please try again later.", "petkit_error": "Unknown error encountered. Please see Home Assistant logs for more details.", - "region_error": "Please select the country associated with your account." + "region_error": "Please select the country associated with your account.", + "timezone_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." }, "abort": { "already_configured": "PetKit account is already configured", diff --git a/custom_components/petkit/translations/en.json b/custom_components/petkit/translations/en.json index f3e46cd..8af2326 100644 --- a/custom_components/petkit/translations/en.json +++ b/custom_components/petkit/translations/en.json @@ -10,7 +10,8 @@ "no_devices": "No devices found on account", "server_busy": "PetKit servers are busy. Please try again later.", "petkit_error": "Unknown error encountered. Please see Home Assistant logs for more details.", - "region_error": "Please select the country associated with your account." + "region_error": "Please select the country associated with your account.", + "timezone_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." }, "step": { "user": { diff --git a/custom_components/petkit/translations/hr.json b/custom_components/petkit/translations/hr.json index 60eb275..7f00452 100644 --- a/custom_components/petkit/translations/hr.json +++ b/custom_components/petkit/translations/hr.json @@ -10,7 +10,8 @@ "no_devices": "Na vašem računu nisu pronađeni uređaji", "server_busy": "PetKit serveri su zauzeti. Molimo pokušajte ponovo kasnije.", "petkit_error": "Došlo je do nepoznate pogreške. Za više detalja pogledajte Home Assistant zapisnike.", - "region_error": "Odaberite državu povezanu s vašim računom." + "region_error": "Odaberite državu povezanu s vašim računom.", + "timezone_error": "Vremenska zona nije pronađena. Ako pokrećete Home Assistant kao samostalni Docker spremnik, morate definirati TZ varijablu." }, "step": { "user": { diff --git a/custom_components/petkit/util.py b/custom_components/petkit/util.py index 5244a2a..5799ee5 100644 --- a/custom_components/petkit/util.py +++ b/custom_components/petkit/util.py @@ -5,7 +5,7 @@ import async_timeout from petkitaio import PetKitClient -from petkitaio.exceptions import AuthError, PetKitError, RegionError, ServerError +from petkitaio.exceptions import AuthError, PetKitError, RegionError, ServerError, TimezoneError from homeassistant.core import HomeAssistant from homeassistant.helpers.aiohttp_client import async_get_clientsession @@ -23,13 +23,16 @@ async def async_validate_api(hass: HomeAssistant, email: str, password: str, reg region=region, timeout=TIMEOUT, ) - try: async with async_timeout.timeout(TIMEOUT): devices_query = await client.get_device_roster() except AuthError as err: 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.' + LOGGER.error(f'{error}') + raise TimezoneError(error) except ServerError as err: LOGGER.error(f'PetKit servers are busy.Please try again later.') raise ServerError(err)