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
This is a quick one, it's been forever since I've posted here. After moving back…
Simple command turned crazy. I ended up coming up with this due to the fact…
Phew, this one took a minute to figure out. ConnectWise has a form based documents…
I've found myself at a new job, recreating many of the processes that I spent…
Wow, it's been a while since I've done a real post on this site. I've…
When using AutoTask's API it's required to lookup a various amount of picklist values that…