XBMC Automation with Smartthings
Let me start out by saying “I’ve learned so much from this site”. The developers and user community is just awesome. I browse the threads everyday, to the point of an addiction, but this stuff is just so cool to tinker with.
Well, here we go… I I figured out how to automate XBMC Play, Pause, and Stop functions in XBMC with Smartthings.
Prerequisites: XBMC ( I’m running Openelec), XBMC Add-on “ XBMC CallBacks” , Smartthings Endpoint Example.
I will not go into details about XBMC directories, installing add-ons, etc… for the sake of time
Here are the steps
You’ll need to create python scripts that execute the commands to hit the Endpoint URL for your devices.
I created scripts called Movie_Play.py, Movie_Pause.py, Movie_Resume.py and Movie_Stop.py
Place the scripts in a directory that is accessible from the XBMC file manager.
For Testing: I placed the scripts in the downloads directory for XBMC
The scripts will look like the following:
#!/usr/bin/python
import xbmc
import urllib2
urllib2.urlopen(‘Copy and Paste your URL from the Endpoint Example Here’)
Note: Make sure the scripts have execute permissions.
Example:
The Play script I created turns off the living room lights and turns on the back lamps. This is accomplished by copying the OFF URL for the living rooms lights and copying the ON URL for the back lamps. The Pause turns the living room lights back ON via the ON URL string and the Resume turns the lights back off via the OFF URL string.
- Now that we have the scripts created. We need to install the XBMC add-on called “XBMC Callbacks”. You can download the add-on from here - http://forum.xbmc.org/showthread.php?tid=151011
- Copy the zip file over to a XBMC directory.
- Go to the add-on section in XBMC and choose to install from Zip file.
- Go to enabled add-ons - then services - then XBMC callbacks
- Click Configure - Click the section that states “ Player starts” - point this to the script you created - Example: Movie_Play.py - then configure the other sections pause, resume, and stop by pointing those sections to your other scripts that were created.
Note: You will need to reboot XBMC for the service to start
7. After XBMC is back up, test the scripts out by playing a movie, then pause and resume to see if everything is working correctly.