From 8733751e38b84fcc58d46d648aa0aef75a1f5498 Mon Sep 17 00:00:00 2001 From: zim514 Date: Sun, 31 Mar 2024 11:11:09 -0400 Subject: [PATCH] Handle unconfigured sunset --- script.service.hue/addon.xml | 2 +- script.service.hue/resources/lib/hue.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/script.service.hue/addon.xml b/script.service.hue/addon.xml index 02a57534..1e97387c 100644 --- a/script.service.hue/addon.xml +++ b/script.service.hue/addon.xml @@ -1,4 +1,4 @@ - + diff --git a/script.service.hue/resources/lib/hue.py b/script.service.hue/resources/lib/hue.py index 43c6ab24..7c81022a 100644 --- a/script.service.hue/resources/lib/hue.py +++ b/script.service.hue/resources/lib/hue.py @@ -305,11 +305,13 @@ def _check_version(self): return False def update_sunset(self): - geolocation = self.make_api_request("GET", "geolocation") # TODO: Support cases where geolocation is not configured on bridge. + geolocation = self.make_api_request("GET", "geolocation") xbmc.log(f"[SCRIPT.SERVICE.HUE] v2 update_sunset(): geolocation: {geolocation}") sunset_str = self.search_dict(geolocation, "sunset_time") if sunset_str is None: - reporting.process_exception(f"Sunset time not found in geolocation response: {geolocation}", logging=True) + xbmc.log(f"[SCRIPT.SERVICE.HUE] Sunset not found; configure Hue geolocalisation") + notification(_("Hue Service"), _("Configure Hue Home location to use Sunset time, defaulting to 19:00"), icon=xbmcgui.NOTIFICATION_ERROR) + self.sunset = convert_time("19:00") return self.sunset = convert_time(sunset_str)