Skip to content

Commit

Permalink
Merge pull request #21 from zim514/dev
Browse files Browse the repository at this point in the history
v0.7.8
  • Loading branch information
Snapcase authored Aug 8, 2019
2 parents 5be153b + c78fb37 commit e7bb5a0
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 57 deletions.
38 changes: 5 additions & 33 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.7.7">
<addon id="script.service.hue" name="Hue Service" provider-name="zim514" version="0.7.8">
<requires>
<import addon="xbmc.python" version="2.26.0" />
<import addon="script.module.requests" version="2.22.0" />
Expand All @@ -22,7 +22,10 @@
<summary lang="en_GB">Automate Hue lights with Kodi playback</summary>
<description lang="en_GB">Automate your Philips Hue lights with Kodi. Create multi-room scenes that run when you Play, Pause or Stop media playback. Create and delete multi-room scenes from add-on settings then select which to apply for different Playback events. Can use Hue's sunrise and sunset times to automatically disable the service during daytime and turn on the lights at sunset during playback. Includes experimental Ambilight support. Check forum for more information.</description>
<disclaimer lang="en_GB">Automate Hue lights with Kodi playback</disclaimer>
<news>v0.7.7:
<news>v0.7.8:
- Various crash fixes
- Fix pause and stop
v0.7.7:
- Fix Video activation conditions not being respected in some cases
v0.7.6:
- Fix ambilight activation at sunset not working.
Expand All @@ -47,37 +50,6 @@ v0.6.0:
- Support multiple colours
v0.5.0:
- Experimental Ambilight support. See Forum for more information
v0.4.2:
- Clean-up and improve settings dialogue
- Code style fixes
v0.4.1:
- Switch to kodi-six from future
v0.4.0:
- Add UPNP support
- Add activation schedule support
v0.3.7
- Fix crash at sunset
v0.3.6:
- Fix logging system crash
v0.3.5:
- Make media type detection more reliable
- Remove deprecated settings
- Change some settings to booleans
- Fix broken daytime settings
v0.3.2:
- Crash fix
v0.3.1:
- Crash fix
- Basic connection error handling
v0.3.0:
- Support different behaviours for different media types
v0.2.8:
- Python 2/3 support
v0.2.7:
- Support optional logging to external file
- Removed half translated French
v0.2.6:
- Improve logging system
</news>
</extension>
</addon>
Expand Down
1 change: 1 addition & 0 deletions script.service.hue/resources/lib/AmbiGroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def onAVStarted(self):
except QhueException as e:
logger.debug("Ambi: Initial Hue call fail: {}".format(e))

self.state = STATE_PLAYING
self.ambiRunning.set()
ambiLoopThread=Thread(target=self._ambiLoop,name="_ambiLoop")
ambiLoopThread.daemon = True
Expand Down
46 changes: 23 additions & 23 deletions script.service.hue/resources/lib/KodiGroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,47 +66,47 @@ def flash(self):

def onAVStarted(self):
logger.info("In KodiGroup[{}], onPlaybackStarted. Group enabled: {},startBehavior: {} , isPlayingVideo: {}, isPlayingAudio: {}, self.mediaType: {},self.playbackType(): {}".format(self.kgroupID, self.enabled,self.startBehavior, self.isPlayingVideo(),self.isPlayingAudio(),self.mediaType,self.playbackType()))
self.state = STATE_PLAYING

#If video group, check video activation. Otherwise it's audio so ignore this and check other conditions.
if self.isPlayingVideo() and self.mediaType == VIDEO:
self.videoInfoTag=self.getVideoInfoTag()
if not self.checkVideoActivation(self.videoInfoTag):
return

else:
self.videoInfoTag = None
globals.lastMediaType = self.playbackType()
if self.enabled and self.checkActiveTime() and self.startBehavior and self.mediaType == self.playbackType():
try:
self.state = STATE_PLAYING
self.groupResource.action(scene=self.startScene)
except QhueException as e:
logger.error("onAVStarted: Hue call fail: {}".format(e))


def onPlayBackStopped(self):
logger.info("In KodiGroup[{}], onPlaybackStopped() , mediaType: {}, lastMediaType: {} ".format(self.kgroupID,self.mediaType,globals.lastMediaType))
self.state = STATE_IDLE
if self.enabled and self.checkActiveTime() and self.stopBehavior and self.mediaType == globals.lastMediaType:
if self.mediaType == VIDEO and not self.checkVideoActivation(self.videoInfoTag):
return
try:
xbmc.sleep(200) #sleep for any left over ambilight calls to complete first.
self.groupResource.action(scene=self.stopScene)
except QhueException as e:
logger.error("onPlaybackStopped: Hue call fail: {}".format(e))
if self.state == STATE_PLAYING or self.state==STATE_PAUSED:
if self.enabled and self.checkActiveTime() and self.stopBehavior and self.mediaType == globals.lastMediaType:
try:
xbmc.sleep(200) #sleep for any left over ambilight calls to complete first.
self.state = STATE_IDLE
self.groupResource.action(scene=self.stopScene)
except QhueException as e:
logger.error("onPlaybackStopped: Hue call fail: {}".format(e))


def onPlayBackPaused(self):
logger.info("In KodiGroup[{}], onPlaybackPaused() , isPlayingVideo: {}, isPlayingAudio: {}".format(self.kgroupID,self.isPlayingVideo(),self.isPlayingAudio()))
self.state = STATE_PAUSED
if self.enabled and self.checkActiveTime() and self.pauseBehavior and self.mediaType == self.playbackType():
self.lastMediaType = self.playbackType()
if self.mediaType == VIDEO and not self.checkVideoActivation(self.videoInfoTag):
return
try:
xbmc.sleep(200) #sleep for any left over ambilight calls to complete first.
self.groupResource.action(scene=self.pauseScene)
except QhueException as e:
logger.error("onPlaybackStopped: Hue call fail: {}".format(e))
if self.state == STATE_PLAYING:
if self.enabled and self.checkActiveTime() and self.pauseBehavior and self.mediaType == self.playbackType():
self.lastMediaType = self.playbackType()
if self.mediaType == VIDEO and not self.checkVideoActivation(self.videoInfoTag):
return
try:
xbmc.sleep(200) #sleep for any left over ambilight calls to complete first.
self.state = STATE_PAUSED
self.groupResource.action(scene=self.pauseScene)
except QhueException as e:
logger.error("onPlaybackStopped: Hue call fail: {}".format(e))


def onPlayBackResumed(self):
Expand Down Expand Up @@ -162,7 +162,7 @@ def checkActiveTime(self):
return True
logger.debug("Disabled by schedule time")
return False
logger.debug("Schedule not enabled")
logger.debug("Schedule not enabled, ignoring")
return True


Expand Down
2 changes: 1 addition & 1 deletion script.service.hue/resources/lib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def service():

if globals.settingsChanged:
kgroups = kodiHue.setupGroups(bridge, globals.reloadFlash)
ambiGroup.setup(monitor,bridge, kgroupID=3, flash=globals.reloadFlash, mediaType=1)
ambiGroup.setup(monitor,bridge, kgroupID=3, flash=globals.reloadFlash)
globals.settingsChanged = False


Expand Down

0 comments on commit e7bb5a0

Please sign in to comment.