diff --git a/custom_components/entity_tz/helpers.py b/custom_components/entity_tz/helpers.py index 13a04e4..261ed3a 100644 --- a/custom_components/entity_tz/helpers.py +++ b/custom_components/entity_tz/helpers.py @@ -7,6 +7,7 @@ from enum import Enum, auto from functools import lru_cache import logging +import struct from typing import Any, cast from zoneinfo import available_timezones @@ -80,7 +81,13 @@ def _get_tz_from_loc(tzf: TimezoneFinder, lat: float, lng: float) -> tzinfo | No This must be run in an executor since timezone_at may do file I/O. """ - if (tz_name := tzf.timezone_at(lat=lat, lng=lng)) is None: + try: + if (tz_name := tzf.timezone_at(lat=lat, lng=lng)) is None: + return None + except struct.error as err: + _LOGGER.debug( + "Getting time zone at (%f, %f) resulted in error: %r", lat, lng, err + ) return None return dt_util.get_time_zone(tz_name)