Michael,
I'm not sure if you are familiar with python or not I figure you are though. So do you see anything that just stands out in this code that would cause it to respond slow? I am seeing it take around 10 seconds once I trigger the control section of code to give me back a status update of the device that was triggered. Seams like an awful long time for update back.
Thanks for your time guys
global app
import app
def connect():
#procedure is used to make connection to the ISY device
import urllib2, urllib, sys
username = 'admin'
password = 'admin'
topurl = 'http://192.168.2.13:81'
auth_handler = urllib2.HTTPPasswordMgrWithDefaultRealm()
auth_handler.add_password(None, uri=topurl,user=username,passwd=password)
handler = urllib2.HTTPBasicAuthHandler(auth_handler)
opener = urllib2.build_opener(handler)
urllib2.install_opener(opener)
return topurl
def control(deviceID,function,level):
#procedure used to control devices ie switch them on and off.
import urllib2, urllib, sys
topurl = app.isy.connect()
print "topurl is " + (topurl)
print "device id is" + (deviceID)
if function == 'DON' and level != "":
theurl = topurl+'/rest/nodes/' + deviceID + '/cmd/'+function
else:
theurl = topurl+'/rest/nodes/' + deviceID + '/cmd/'+function+'/'+level
#normalize the URL
theurl = urllib.quote(theurl, safe="%/:=&?~#+!$,;'@()*[]")
print "the url is " +theurl
pagehandle = urllib2.urlopen(theurl)
app.isy.status(deviceID,topurl)
def status(deviceID,topurl):
#procedure will get the status of the device that was just triggered and set the value in the ignition tag.
import urllib2,urllib
import sys, system
import xml.etree.ElementTree as ET
theurl = topurl+'/rest/status/' + deviceID
theurl = urllib.quote(theurl, safe="%/:=&?~#+!$,;'@()*[]")
response=urllib2.urlopen(theurl)
mytree = ET.parse(response)
value = mytree.find('property').get('value')
system.tag.write("ISY/"+deviceID,value)