Here’s a simple Python script to run on your XBMC box that will launch scenes based on if XBMC is playing, paused, stopped, etc. Remember to change the scene numbers.
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://10.10.0.6:49451/data_request?id=lu_action&output_format=xml&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum=19'")
def onPlayBackEnded(self):
if (VIDEO == 1):
os.system("wget -b -O /dev/null -o /dev/null 'http://10.10.0.6:49451/data_request?id=lu_action&output_format=xml&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum=2'")
def onPlayBackStopped(self):
if (VIDEO == 1):
os.system("wget -b -O /dev/null -o /dev/null 'http://10.10.0.6:49451/data_request?id=lu_action&output_format=xml&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum=2'")
def onPlayBackPaused(self):
if xbmc.Player().isPlayingVideo():
os.system("wget -b -O /dev/null -o /dev/null 'http://10.10.0.6:49451/data_request?id=lu_action&output_format=xml&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum=18'")
def onPlayBackResumed(self):
if xbmc.Player().isPlayingVideo():
os.system("wget -b -O /dev/null -o /dev/null 'http://10.10.0.6:49451/data_request?id=lu_action&output_format=xml&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum=19'")
VIDEO = 0
while(1):
if xbmc.Player().isPlaying():
if xbmc.Player().isPlayingVideo():
VIDEO = 1
else:
VIDEO = 0
xbmc.sleep(1000)
while(1):
if xbmc.Player().isPlaying():
if xbmc.Player().isPlayingVideo():
VIDEO = 1
else:
VIDEO = 0
xbmc.sleep(1000)
Anything else I need to do to that? I saw that 3480 is the default port in some other posts. How do I test these http commands? I tried a normal browser and nothing. (I added a space between ht tp so I could post the full code)
This should launch the scene when you open the URL in a normal browser, notice I’m using port 49451 which isn’t user configurable. Do you get any output when you launch that in a browser? It normally comes back with an error and says “OK” and launches the scene for me immediately.
So you don’t have to change the ip from http://10.10.0.6 ? Is that the micasaverde server address or just a local redirect to the ip of the vera 3 on your network
After seeing your comment on my site I was looking around to see if autoexec.py is really gone in Eden and I’m reading some conflicting things. Have you tried my instructions as-is and it’s not working?
I tried instructions as is, but I can’t figure out where the autoexec.py is. Looked around, nowhere to be found.
I did some researching on the xbmc eden wiki, and it says there isn’t an autoexec.py anymore, and things are all plugins, addons, or services and need an “addon.xml”
There’s no autoexec.py by default in Dharma either, check my site and I said where all the scripts should be and what they should be named. Updated the post to make it a bit more clear.
As I have posted on your blog…I have this all working on my windows 7 HTPC except that whenever the wget command is issued, a command prompt window flashes up on the desktop…which minimizes XBMC. I have tried using the -q argument and > nul etc but nothing seems to work…
Can anyone help me with this?
I am going to write a very simple plugin which provides some variables which can be set by such scripts from xbmc. The integration in scenes can then be done directly on the vera by using events. Should be ready in 1-2 weeks, first need to do some testing, but it is simple. In a second step I plan to add full upnp remote functions for xbmc so that xbmc can be fully controlled from the vera (comparable to the PopBox plugin I published).
@baxy_AU: Would you mind posting the script with your final solution? I am still not sure how I could make the scripts cross-plattform compatible in an easy way…
IMO this will be useful if the Scenes are triggered based on XBMC actions that are specific to what a Scene really is (Watch Movies, Watch TV, Listen to Music, etc)… vs what the XBMC JSON interface provides today (play, stop, fast forward, etc) which is 99% useless for HA.
I can already pull all items based on IR that EventGhost already logs - though this is not ideal, it works. I would much prefer the XBMC JSON send events that are usable but it seems the XBMC devs don’t have any interest in HA.
In order for a completely usable HA solution to be integrated with XBMC will need to know specifics like…
what XBMC section has been selected: Movies, TV, Photos, Favorite=“New”, etc. This is the only way to trigger events relevant to what is happening.
name of the video, music, photo, etc is showing/playing (less important but nice as a status, or for spying on what others are doing when you are not there)
IMO The python code Hackworth made somehow lets you do that.
You can send different wget commands for music playback or video playback (and I guess it can send different ones for photo slideshow), and on any of those categories an action for play/stop/pause/start/end and so on.
The only thing it doesn’t seem to do is make a differenciation between film or tv show playback, but in my case, that’s not a problem since I would use the same scene for both playbacks.
[quote=“chixxi, post:13, topic:169994”]I am going to write a very simple plugin which provides some variables which can be set by such scripts from xbmc. The integration in scenes can then be done directly on the vera by using events. Should be ready in 1-2 weeks, first need to do some testing, but it is simple. In a second step I plan to add full upnp remote functions for xbmc so that xbmc can be fully controlled from the vera (comparable to the PopBox plugin I published).
@baxy_AU: Would you mind posting the script with your final solution? I am still not sure how I could make the scripts cross-plattform compatible in an easy way…[/quote]
here is my version of the xbmc script…I hope its of some use to you:
Just to forget about the classic stuff. Did you put the .py files in the correct folder? Are you using Linux? In that case, are filename case-sensitive, including upper and lower case letters? do you have playeractions.py, iddletime.py or both? finally, do you have multiple profiles?
Fron Jordanhackworth
What this does is launch the two scripts from the default home directory of your master profile. If you’re using multiple profiles you’ll have to modify the special:// directory to match the other profile.