From ba11722e773f9c766edaacfb0bfc7a22dbe031d1 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 23 Feb 2026 15:00:17 -0600 Subject: [PATCH] [time] Skip POSIX TZ validation for empty timezone strings Empty timezone strings are valid (meaning UTC/no timezone). The parse_posix_tz_python() validation should only run on non-empty strings. --- esphome/components/time/__init__.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/esphome/components/time/__init__.py b/esphome/components/time/__init__.py index 8a33e042ee..161a334999 100644 --- a/esphome/components/time/__init__.py +++ b/esphome/components/time/__init__.py @@ -280,11 +280,12 @@ def validate_tz(value: str) -> str: if tzfile is not None: value = _extract_tz_string(tzfile) - # Validate that the POSIX TZ string is parseable - try: - parse_posix_tz_python(value) - except ValueError as e: - raise cv.Invalid(f"Invalid POSIX timezone string '{value}': {e}") from e + # Validate that the POSIX TZ string is parseable (skip empty strings) + if value: + try: + parse_posix_tz_python(value) + except ValueError as e: + raise cv.Invalid(f"Invalid POSIX timezone string '{value}': {e}") from e return value