From 7ea96e7167063243b147ec38b4e270a56461e38d Mon Sep 17 00:00:00 2001 From: Yo-han <197600+yo-han@users.noreply.github.com> Date: Thu, 1 Jun 2023 21:05:28 +0200 Subject: [PATCH] fix: timezone default (#26) --- custom_components/carelink/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/custom_components/carelink/__init__.py b/custom_components/carelink/__init__.py index 6a968b2..1402a7d 100644 --- a/custom_components/carelink/__init__.py +++ b/custom_components/carelink/__init__.py @@ -127,12 +127,16 @@ async def _async_update_data(self): data = {} last_sg = {} + clientTimezone = "Europe/London" await self.client.login() recent_data = await self.client.get_recent_data() + if "clientTimeZoneName" in recent_data: + clientTimezone = recent_data["clientTimeZoneName"] + timezone_map = MS_TIMEZONE_TO_IANA_MAP.setdefault( - recent_data.setdefault("clientTimeZoneName"), "Europe/London" + clientTimezone, "Europe/London" ) timezone = ZoneInfo(timezone_map)