Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.3.1 #8

Merged
merged 5 commits into from
Jun 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,7 @@
- Uses Qhue (C) Quentin Stafford-Fraser - https://github.com/quentinsf/qhue
<!--stackedit_data:
eyJoaXN0b3J5IjpbMTI2MDI1ODI4NywtMjEzNDQ5MzI0Nl19
-->
=======
eyJoaXN0b3J5IjpbMTAzODI1NzU3OCwtMjEzNDQ5MzI0Nl19
>>>>>>> README.md updated from https://stackedit.io/
-->
16 changes: 10 additions & 6 deletions 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="0.3.0">
<addon id="script.service.hue" name="Hue Service" provider-name="zim514" version="0.3.1">

<requires>
<import addon="xbmc.python" version="2.26.0" />
Expand All @@ -22,15 +22,19 @@
<platform>all</platform>
<license>MIT License</license>
<news>
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
</news>
<assets>
<icon>resources/icons/icon.png</icon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Addon Name: Hue Service
# Addon id: script.service.hue
# Addon Provider: zim514
msgid ""
msgid ""
msgstr ""

msgctxt "#1000"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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 ""
4 changes: 2 additions & 2 deletions script.service.hue/resources/lib/KodiGroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -192,6 +190,8 @@ def playbackType(self):
mediaType=VIDEO
elif self.isPlayingAudio():
mediaType=AUDIO
else:
mediaType=None
return mediaType


Expand Down
31 changes: 21 additions & 10 deletions script.service.hue/resources/lib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import sys
from logging import getLogger
from requests.exceptions import ConnectionError

import xbmcgui

Expand Down Expand Up @@ -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():
Expand All @@ -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
Expand Down
13 changes: 8 additions & 5 deletions script.service.hue/resources/lib/language.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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