I have XBMC talking to Indigo and acting upon XBMC's current state.
When a video is played, Indigo dims the lights. Pause, stop and the lights brighten, and so on.
If XBMC is left idle too long, the TV is turned off via IR.
I tried to Use cURL, but didn't have any luck, so I installed WGET.
- Code: Select all
# light.py
import xbmc,xbmcgui
import subprocess,os
class MyPlayer(xbmc.Player) :
def __init__ (self):
xbmc.Player.__init__(self)
def onPlayBackStarted(self):
if xbmc.Player().isPlayingVideo():
os.system("wget -b -O /dev/null -o /dev/null 'http://user:password@127.0.0.1:8176/actions/Movie%20Lights%20Playing?_method=execute'")
def onPlayBackEnded(self):
if (VIDEO == 1):
os.system("wget -b -O /dev/null -o /dev/null 'http://user:password@127.0.0.1:8176/actions/Movie%20Lights%20End?_method=execute'")
def onPlayBackStopped(self):
if (VIDEO == 1):
os.system("wget -b -O /dev/null -o /dev/null 'http://user:password@127.0.0.1:8176/actions/Movie%20Lights%20Stop?_method=execute'")
def onPlayBackPaused(self):
if xbmc.Player().isPlayingVideo():
os.system("wget -b -O /dev/null -o /dev/null 'http://user:password@127.0.0.1:8176/actions/Movie%20Lights%20Pause?_method=execute'")
def onPlayBackResumed(self):
if xbmc.Player().isPlayingVideo():
os.system("wget -b -O /dev/null -o /dev/null 'http://user:password@127.0.0.1:8176/actions/Movie%20Lights%20Resume?_method=execute'")
def OnScreensaverActivated(self):
if (VIDEO == 0):
os.system("wget -b -O /dev/null -o /dev/null 'http://user:password@127.0.0.1:8176/actions/Movie%20Lights%20TV%20Off?_method=execute'")
def OnScreensaverDeactivated(self):
if xbmc.Player().isPlayingVideo():
os.system("wget -b -O /dev/null -o /dev/null 'http://user:password@127.0.0.1:8176/actions/Movie%20Lights%20TV%20On?_method=execute'")
player=MyPlayer()
while(not xbmc.abortRequested):
if xbmc.Player().isPlayingVideo():
VIDEO = 1
else:
VIDEO = 0
xbmc.sleep(3000)
- Code: Select all
# idletime.py
import xbmc,xbmcgui
import subprocess,os
ILT = 0
IDLE_TIME_MIN = 15
s = 0
while(not xbmc.abortRequested):
it = xbmc.getGlobalIdleTime()
s = ((IDLE_TIME_MIN * 60) - it )
if (s > 0):
if (ILT == 1):
if xbmc.Player().isPlayingVideo():
pass
else:
os.system("wget -b -O /dev/null -o /dev/null 'http://user:password@127.0.0.1:8176/actions/Movie%20Lights%20TV%20On?_method=execute'")
ILT = 0
elif (s < 0):
if (ILT == 0 and xbmc.Player().isPlayingVideo() == False):
os.system("wget -b -O /dev/null -o /dev/null 'http://user:password@127.0.0.1:8176/actions/Movie%20Lights%20TV%20Off?_method=execute'")
ILT = 1
xbmc.sleep(5000)
If anyone knows the equivalent cURL commands I would like to give them a shot.