Thanks, but spawning an OS task is a last resort IMHO. Although we're on a Mac, cross platform scripting is always something to consider.
Using a Google Chrome REST Client App didn't bring me much further, so I took your approach of using a curl library:
pycurl and here's what I've come up with:
- Code: Select all
import pycurl
c = pycurl.Curl()
c.setopt(pycurl.URL, "http://indigo.local:8176/devices/DiningRoom%20-%20OverheadLight")
c.setopt(pycurl.HTTPAUTH, pycurl.HTTPAUTH_DIGEST)
c.setopt(pycurl.USERPWD, "admin:admin")
c.setopt(pycurl.CUSTOMREQUEST, "PUT")
c.setopt(pycurl.POSTFIELDS, "isOn=1")
c.perform()
c.close()
As I suspected the way the payload is sent across probably does the trick. A mix and match of PUT and POST. The Indigo REST API expects a PUT (POST gets a 405), but then POSTs form data. I guess the curl command is doing that by default.
Since I've been sniffing around an application with an AngularJS frontend and a RESTeasy Java backend using JSON, I would love Indigo to head in that direction. I thought I've read somewhere that Matt and Jay are considering refactoring their REST API (or having done so already with the TouchApp 2.0). Any light on this guys?