Posts: 3
Joined: Sep 2010
Reputation:
0
A plugin for the tellstick would be indeed very nice.
Would be enough a page with a few buttons for switch on/off devices.
Regards
Fux
Posts: 3
Joined: Jan 2011
Reputation:
0
i got an python script a friend of mine code for me to turn the lights off/on when i play/stop/pause a movie, its just running in the bakgrund on the computer
Posts: 3
Joined: Jan 2011
Reputation:
0
Here is mine python script, its lookup the currently now playing every 5 sek works great:
# -*- coding: utf-8 -*-
# __ ______ __ __ ____ #
# \ \/ / __ )| \/ |/ ___|_ __ ___ #
# \ /| _ \| |\/| | | | '_ ` _ \ #
# / \| |_) | | | | |___| | | | | | #
# /_/\_\____/|_| |_|\____|_| |_| |_| #
# #
#-#-#-#-#-#-#-#-#-#-#-#-# SETTINGS #-#-#-#-#-#-#-#-#-#-#-#-#
# #
# url - The url to connect to.
#
url = 'http://aa:8080/xbmcCmds/xbmcHttp?command=getcurrentlyplaying'
#
# update_frequency - Number of seconds between updates
#
update_frequency = 5
#
# cmd_play2pause - Command to execute when XBMC playStatus goes from
# "playing" to "paused".
#
cmd_play2pause = 'tdtool.exe --on 7 --on 6'
#
# cmd_pause2play - Command to execute when XBMC playStatus goes from
# "paused" to "playing".
#
cmd_pause2play = 'tdtool.exe --off 6 --off 7'
#
# cmd_none2play - Command to execute when XBMC playStatus goes from
# none to "playing".
#
cmd_none2play = 'tdtool.exe --off 6 --off 7'
#
# cmd_play2none - Command to execute when XBMC playStatus goes from
# "playing" to none.
#
cmd_play2none = 'tdtool.exe --on 7'
#
# cmd_pause2none - Command to execute when XBMC playStatus goes from
# "paused" to none.
#
cmd_pause2none = '' #Don't do anything
# #
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
#-#-#-#-#-#-#-#-#-# CODE BELOW, DON'T EDIT #-#-#-#-#-#-#-#-#-#
#
import datetime
import os
import re
import subprocess
import sys
import time
import urllib
def log(message, output = sys.stdout):
ts = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
f = open(os.path.join(sys.path[0], 'xbmcm.log'), 'a')
#if VERBOSE:
print >> output, '[%s] %s' % (ts, message)
f.write('[%s] %s\n' % (ts, message))
f.close()
log('XBMXmonitor is starting...')
playstatus = -1
while True:
try:
data = urllib.urlopen(url).read()
data = re.sub(r'<[^>]+>', '', data).strip().split('\n')
status = {}
for x in data:
if ':' in x:
k, v = x.split(':', 1)
status[k.lower().strip()] = v.strip()
if playstatus == -1:
if 'playstatus' in status:
playstatus = status['playstatus']
else:
playstatus = None
else:
if 'playstatus' in status:
np = status['playstatus']
else:
np = None
if playstatus == 'Playing':
if np == None:
log('Status changed: Playing -> None')
subprocess.Popen(cmd_play2none.split(' '))
elif np == playstatus:
pass
else:
log('Status changed: Playing -> Paused')
subprocess.Popen(cmd_play2pause.split(' '))
elif playstatus == None:
if np == 'Playing':
log('Status changed: None -> Playing')
subprocess.Popen(cmd_none2play.split(' '))
else:
if np == None:
log('Status changed: Paused -> None')
subprocess.Popen(cmd_pause2none.split(' '))
elif np == 'Playing':
log('Status changed: Paused -> Playing')
subprocess.Popen(cmd_pause2play.split(' '))
playstatus = np
except Exception, e:
log('Unable to connect to xbmc %s. Retrying in 5 minutes' % e, sys.stderr)
time.sleep(4*60)
time.sleep(update_frequency)