diff --git a/README.md b/README.md index 39dabc89..29d1863b 100644 --- a/README.md +++ b/README.md @@ -42,4 +42,7 @@ - Uses Qhue (C) Quentin Stafford-Fraser - https://github.com/quentinsf/qhue \ No newline at end of file +======= +eyJoaXN0b3J5IjpbMTAzODI1NzU3OCwtMjEzNDQ5MzI0Nl19 +>>>>>>> README.md updated from https://stackedit.io/ +--> diff --git a/script.service.hue/addon.xml b/script.service.hue/addon.xml index 02cf4fdb..a3fc50c2 100644 --- a/script.service.hue/addon.xml +++ b/script.service.hue/addon.xml @@ -1,4 +1,4 @@ - + @@ -22,15 +22,19 @@ all MIT License +v0.3.1: + - Crash fix + - Basic connection error handling + v0.3.0: - - Support different behaviours for different media types + - Support different behaviours for different media types v0.2.8: - - Python 2/3 support + - Python 2/3 support v0.2.7: - - Support optional logging to external file - - Removed half translated French + - Support optional logging to external file + - Removed half translated French v0.2.6: - - Improve logging system + - Improve logging system resources/icons/icon.png diff --git a/script.service.hue/resources/language/resource.language.en_GB/strings.po b/script.service.hue/resources/language/resource.language.en_GB/strings.po index 29821dcc..63f68c53 100644 --- a/script.service.hue/resources/language/resource.language.en_GB/strings.po +++ b/script.service.hue/resources/language/resource.language.en_GB/strings.po @@ -2,7 +2,7 @@ # Addon Name: Hue Service # Addon id: script.service.hue # Addon Provider: zim514 -msgid "" +msgid "" msgstr "" msgctxt "#1000" @@ -73,12 +73,10 @@ msgctxt "#32102" msgid "Debug Logs" msgstr "Debug Logs" - msgctxt "#32105" msgid "Separate debug log" msgstr "Separate debug log" - msgctxt "#5110" msgid "Initial flash" msgstr "Initial flash" @@ -415,3 +413,11 @@ msgstr "" msgctxt "#30046" msgid "Adjust lights to desired state in the Hue App to save as new scene." msgstr "" + +msgctxt "#30047" +msgid "Connection lost. Check settings. Shutting down" +msgstr "" + +msgctxt "#30048" +msgid "Connection lost. Trying again in 5 minutes" +msgstr "" diff --git a/script.service.hue/resources/lib/KodiGroup.py b/script.service.hue/resources/lib/KodiGroup.py index 075b4c83..18955e75 100644 --- a/script.service.hue/resources/lib/KodiGroup.py +++ b/script.service.hue/resources/lib/KodiGroup.py @@ -34,8 +34,6 @@ def __init__(self): def readSettings(self): self.enabled=get_setting_as_bool("group{}_enabled".format(self.kgroupID)) - self.fadeTime=get_setting_as_int("group{}_fadeTime".format(self.kgroupID)) * 10 #Stored as seconds, but Hue API expects multiples of 100ms. - self.forceOn=get_setting_as_bool("group{}_forceOn".format(self.kgroupID)) self.startBehavior=get_setting_as_int("group{}_startBehavior".format(self.kgroupID)) self.startScene=get_setting("group{}_startSceneID".format(self.kgroupID)) @@ -192,6 +190,8 @@ def playbackType(self): mediaType=VIDEO elif self.isPlayingAudio(): mediaType=AUDIO + else: + mediaType=None return mediaType diff --git a/script.service.hue/resources/lib/core.py b/script.service.hue/resources/lib/core.py index 1efc6db0..55eb149e 100644 --- a/script.service.hue/resources/lib/core.py +++ b/script.service.hue/resources/lib/core.py @@ -2,6 +2,7 @@ import sys from logging import getLogger +from requests.exceptions import ConnectionError import xbmcgui @@ -118,8 +119,9 @@ def service(): globals.settingsChanged = False globals.daylight = kodiHue.getDaylight(bridge) kgroups = kodiHue.setupGroups(bridge,initialFlash) - - timer = 60 + + connectionRetries = 0 + timer = 60 #Run loop once on first run # #Ready to go! Start running until Kodi exit. logger.debug('Main service loop starting') while globals.connected and not monitor.abortRequested(): @@ -132,26 +134,35 @@ def service(): kgroups = kodiHue.setupGroups(bridge, reloadFlash) globals.settingsChanged = False - timer = timer + 1 + if timer > 59: + timer = 1 try: previousDaylight = kodiHue.getDaylight(bridge) - #logger.debug('Daylight check: current: {}, previous: {}'.format(globals.daylight, previousDaylight)) + except ConnectionError as error: + + if connectionRetries <= 5: + #TODO: handle bridge IP change + logger.error('Bridge Connection Error. Retry: {}/5 : {}'.format(connectionRetries, error)) + xbmcgui.Dialog().notification(_("Hue Service"), _("Connection lost. Trying again in 5 minutes")) + timer = -240 #set timer to negative 4 minutes + connectionRetries = connectionRetries + 1 + else: + logger.error('Bridge Connection Error. Retry: {}/5. Shutting down : {}'.format(connectionRetries, error)) + xbmcgui.Dialog().notification(_("Hue Service"), _("Connection lost. Check settings. Shutting down")) + globals.connected = False except Exception as error: logger.error('Get daylight exception: {}'.format(error)) - if globals.daylight != previousDaylight : logger.debug('Daylight change! current: {}, previous: {}'.format(globals.daylight, previousDaylight)) + globals.daylight = kodiHue.getDaylight(bridge) if not globals.daylight: kodiHue.sunset(bridge,kgroups) - - - timer = 1 - - + + timer = timer + 1 monitor.waitForAbort(1) logger.debug('Process exiting...') return diff --git a/script.service.hue/resources/lib/language.py b/script.service.hue/resources/lib/language.py index 611c8fb0..e27a6060 100644 --- a/script.service.hue/resources/lib/language.py +++ b/script.service.hue/resources/lib/language.py @@ -72,7 +72,7 @@ def get_string(t): id = _strings.get(t.lower()) if not id: - xbmc.log("LANGUAGE: missing translation for '%s'" % t.lower()) + xbmc.log("ERROR LANGUAGE: missing translation for '%s'" % t.lower()) return t else: if STRDEBUG is True: @@ -90,10 +90,11 @@ def get_string(t): #GENERATED _strings['general'] = 1000 _strings['light groups'] = 1100 -_strings['player actions'] = 32100 -_strings['start/resume video'] = 32201 -_strings['pause video'] = 32202 -_strings['stop video'] = 32203 +_strings['video actions'] = 32100 +_strings['audio actions'] = 32102 +_strings['start/resume'] = 32201 +_strings['pause'] = 32202 +_strings['stop'] = 32203 _strings['scene name'] = 32510 _strings['scene id'] = 32511 _strings['select scene'] = 32512 @@ -189,3 +190,5 @@ def get_string(t): _strings['create new scene'] = 30044 _strings['scene successfully created!'] = 30045 _strings['adjust lights to desired state in the hue app to save as new scene.'] = 30046 +_strings['connection lost. check settings. shutting down'] = 30047 +_strings['connection lost. trying again in 5 minutes'] = 30048