Skip to content

Commit

Permalink
Handle unconfigured sunset
Browse files Browse the repository at this point in the history
  • Loading branch information
zim514 committed Mar 31, 2024
1 parent dcdf1a9 commit 8733751
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion script.service.hue/addon.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<addon id="script.service.hue" name="Hue Service" provider-name="zim514" version="1.5.8">
<addon id="script.service.hue" name="Hue Service" provider-name="zim514" version="1.5.9">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
<import addon="script.module.requests" version="2.27.1"/>
Expand Down
6 changes: 4 additions & 2 deletions script.service.hue/resources/lib/hue.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check notice on line 313 in script.service.hue/resources/lib/hue.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

PEP 8 coding style violation

PEP 8: E501 line too long (149 \> 120 characters)

Check notice on line 313 in script.service.hue/resources/lib/hue.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

PEP 8 coding style violation

PEP 8: E501 line too long (149 \> 120 characters)
self.sunset = convert_time("19:00")
return

self.sunset = convert_time(sunset_str)
Expand Down

0 comments on commit 8733751

Please sign in to comment.