XBMC Integration

Posted on
Tue May 21, 2013 9:41 am
Korey offline
User avatar
Posts: 813
Joined: Jun 04, 2008
Location: Henderson, NV

XBMC Integration

Following steps from here: http://www.jordanhackworth.com/home-aut ... with-xbmc/

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.

--
Korey

Posted on
Tue May 21, 2013 12:17 pm
tenallero offline
Posts: 94
Joined: Oct 31, 2011
Location: Barcelona

Re: XBMC Integration

Hi,


If I want to execute some action:

/usr/bin/curl --digest -u <user>:<password> http://<IndigoIPAdress>:8176/actions/<actionName>?_method=execute

If I want to know the value of an Indigo's variable:

/usr/bin/curl --connect-timeout 3 --digest -u <user>:<password> http://<IndigoIPAdress>:8176/variables/<variableName>


Both curl's request work for me, from OSX and from Linux.
Maybe you must change the curl's path, or not use it.

I hope it helps you.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 21 guests