Here is a simple python script to use the REST code in the ISY (http://universal-devices.com) to control devices that are linked. I’m designing this script to be used inside a script for xbmc. here’s the first part of it. I recommend using scenes for the devicedim, deviceoff, and deviceon array, however you can use the individual devices as well in the array.


import urllib2
import urllib
import sys

devicedim = ['41941']
deviceoff = ['48839']
deviceon = ['62270']
username = 'admin'
password = 'admin'

topurl = 'http://isy'
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, topurl, username, password)
authhandler = urllib2.HTTPBasicAuthHandler(passman)
opener = urllib2.build_opener(authhandler)
urllib2.install_opener(opener)
	
if sys.argv[1] == 'playing':
	for devicex in deviceoff:
		theurl = 'http://isy/rest/nodes/' + devicex + '/cmd/DOF'
		#normalize the URL
		theurl = urllib.quote(theurl, safe="%/:=&?~#+!$,;'@()*[]")
		print (theurl)
		pagehandle = urllib2.urlopen(theurl)
	for devicex in devicedim:
		theurl = 'http://isy/rest/nodes/' + devicex + '/cmd/DON/64'
		#normalize the URL
		theurl = urllib.quote(theurl, safe="%/:=&?~#+!$,;'@()*[]")
		print (theurl)
		pagehandle = urllib2.urlopen(theurl)
elif sys.argv[1] == 'stopped':
	for devicex in deviceon:
		print (devicex)
		theurl = 'http://isy/rest/nodes/' + devicex + '/cmd/DON'
		#normalize the URL
		theurl = urllib.quote(theurl, safe="%/:=&?~#+!$,;'@()*[]")
		print (theurl)
		pagehandle = urllib2.urlopen(theurl)
else:
	print 'no state given'

Usage:

isy-medialights.py playing|stopped