From 5f615468c2976a7490bc807bd260221f569aa477 Mon Sep 17 00:00:00 2001 From: Snapcase Date: Mon, 24 Jun 2019 12:46:48 -0400 Subject: [PATCH 1/5] README.md updated from https://stackedit.io/ --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 39dabc89..35533e5e 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,14 @@ **Kodi Service for Philips Hue** ## Installation +<<<<<<< HEAD 1. [Download latest .zip version](https://github.com/zim514/script.service.hue/releases) 2. [Install to Kodi from Zip](https://kodi.wiki/view/HOW-TO:Install_add-ons_from_zip_files) +======= +[Download latest version](https://github.com/zim514/script.service.hue/releases) +>>>>>>> README.md updated from https://stackedit.io/ ## Features: - Create and delete multi-room LightScenes @@ -41,5 +45,9 @@ - Based on original plugin by cees-elzinga, michaelrcarroll, mpolednik - Uses Qhue (C) Quentin Stafford-Fraser - https://github.com/quentinsf/qhue \ No newline at end of file From 3dfb99b148605e8c7b32dc2915cda1b2b183c5a0 Mon Sep 17 00:00:00 2001 From: zim514 Date: Mon, 24 Jun 2019 14:00:57 -0400 Subject: [PATCH 2/5] assignment crash fix --- README.md | 7 +------ script.service.hue/addon.xml | 14 ++++++++------ script.service.hue/resources/lib/KodiGroup.py | 2 ++ 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 35533e5e..29d1863b 100644 --- a/README.md +++ b/README.md @@ -3,14 +3,10 @@ **Kodi Service for Philips Hue** ## Installation -<<<<<<< HEAD 1. [Download latest .zip version](https://github.com/zim514/script.service.hue/releases) 2. [Install to Kodi from Zip](https://kodi.wiki/view/HOW-TO:Install_add-ons_from_zip_files) -======= -[Download latest version](https://github.com/zim514/script.service.hue/releases) ->>>>>>> README.md updated from https://stackedit.io/ ## Features: - Create and delete multi-room LightScenes @@ -45,9 +41,8 @@ - Based on original plugin by cees-elzinga, michaelrcarroll, mpolednik - Uses Qhue (C) Quentin Stafford-Fraser - https://github.com/quentinsf/qhue \ No newline at end of file +--> diff --git a/script.service.hue/addon.xml b/script.service.hue/addon.xml index 02cf4fdb..0eb495ff 100644 --- a/script.service.hue/addon.xml +++ b/script.service.hue/addon.xml @@ -1,4 +1,4 @@ - + @@ -22,15 +22,17 @@ all MIT License +v0.3.1: + - Crash fix 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/lib/KodiGroup.py b/script.service.hue/resources/lib/KodiGroup.py index 075b4c83..fce589e1 100644 --- a/script.service.hue/resources/lib/KodiGroup.py +++ b/script.service.hue/resources/lib/KodiGroup.py @@ -192,6 +192,8 @@ def playbackType(self): mediaType=VIDEO elif self.isPlayingAudio(): mediaType=AUDIO + else: + mediaType=None return mediaType From da6014dde7cc1d4020be6a48645eab8ff107f9cb Mon Sep 17 00:00:00 2001 From: zim514 Date: Mon, 24 Jun 2019 14:16:04 -0400 Subject: [PATCH 3/5] Don't fetch unused settings --- script.service.hue/resources/lib/KodiGroup.py | 2 -- script.service.hue/resources/lib/core.py | 31 +++++++++++++------ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/script.service.hue/resources/lib/KodiGroup.py b/script.service.hue/resources/lib/KodiGroup.py index fce589e1..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)) diff --git a/script.service.hue/resources/lib/core.py b/script.service.hue/resources/lib/core.py index 1efc6db0..39b3dace 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,Timeout 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 From b34fa7b461cc65f375eb502fd7d60e923e762496 Mon Sep 17 00:00:00 2001 From: zim514 Date: Mon, 24 Jun 2019 15:12:04 -0400 Subject: [PATCH 4/5] Update localizations --- script.service.hue/addon.xml | 2 ++ .../language/resource.language.en_GB/strings.po | 12 +++++++++--- script.service.hue/resources/lib/language.py | 13 ++++++++----- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/script.service.hue/addon.xml b/script.service.hue/addon.xml index 0eb495ff..a3fc50c2 100644 --- a/script.service.hue/addon.xml +++ b/script.service.hue/addon.xml @@ -24,6 +24,8 @@ v0.3.1: - Crash fix + - Basic connection error handling + v0.3.0: - Support different behaviours for different media types v0.2.8: 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/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 From 3a2916de4160098b8a530d90878bacc23b153301 Mon Sep 17 00:00:00 2001 From: zim514 Date: Mon, 24 Jun 2019 15:18:41 -0400 Subject: [PATCH 5/5] remove unused import --- script.service.hue/resources/lib/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script.service.hue/resources/lib/core.py b/script.service.hue/resources/lib/core.py index 39b3dace..55eb149e 100644 --- a/script.service.hue/resources/lib/core.py +++ b/script.service.hue/resources/lib/core.py @@ -2,7 +2,7 @@ import sys from logging import getLogger -from requests.exceptions import ConnectionError,Timeout +from requests.exceptions import ConnectionError import xbmcgui