Ambient tv lighting

I have finally added the ambient lighting behind the tv that I have wanted for ages (at least since removing the manual kind years ago).

I found a script here that I modified to suit my needs;


import xbmc
import subprocess,os

class MyPlayer(xbmc.Player) :

def __init__ (self):

def onPlayBackStarted(self):
if xbmc.Player().isPlayingVideo():
os.system("curl --silent ''")

def onPlayBackEnded(self):
if (VIDEO == 1):
os.system("curl --silent ''")

def onPlayBackStopped(self):
if (VIDEO == 1):
os.system("curl --silent ''")

def onPlayBackPaused(self):
if xbmc.Player().isPlayingVideo():
os.system("curl --silent ''")

def onPlayBackResumed(self):
if xbmc.Player().isPlayingVideo():
os.system("curl --silent ''")


if xbmc.Player().isPlayingVideo():


This seems to be a very popular script so I really have no idea where it originally came from. A couple of notes, in openelec the python library xbmcgui is unavailable. The xbmc.sleep function in the end counts milliseconds, not seconds.

After sticking this in /storage/.xbmc/userdata (once again, I run openelec) on the media center I added it to in /storage/.config (many sources says but that is deprecated in favor of in XBMC Eden) and now the lights turn on when video plays and of when paused or stopped.

On the receiving end a script checks if the sun is up and if not turns the light on.
I might extend this more in the future, but for now it integrates just fine as is.

As a side note; except for the for the code parts I wrote this post in the android wp app and it actually works quite well..


2 thoughts on “Ambient tv lighting

  1. Alex Bergsland

    Hello, you say you are running this on OpenElec?
    What else have you done to make it work?
    I used to have a script (from the source you linked to) when I was running XBMC from Ubuntu on my Xtreamer Ultra.
    I think the script was sending commands to TelldusCore or something like that, an application in Ubuntu.
    But XBMC was to slow and I switched to OpenElec wich runs better but I didnt think it was possible to controll Telldus products from it.
    Is that your own server running something?

    I am using a Tellstick Net at the moment but I still have my Tellstick.

    What else do I need to do to get this going in OpenElec?

    /Alex (från Strängnäs)

  2. henrik Post author

    @Alex Bergsland
    This is on OpenElec and the IP address in the request is a FreeBSD server here at home that does the work with the Tellstick. It basically just parses the request and runs tdtool on or off for lights, except for the lights behind the tv where it runs another wrapper I’ve made which only turns them on after sunset.
    Since the only thing being done on the OpenElec in my setup is a web request this requires another computer for it to work. I’m not sure if the Tellstick Net can be made to work this way.

    Tog det på engelska eftersom det kompletterade posten så pass mycket. Säg gärna till om du undrar över mer!

Leave a Reply

Your email address will not be published. Required fields are marked *