Skip to content

Using curl to interact with cmdr

Brian Gapinski edited this page May 7, 2014 · 3 revisions

It's often useful to use curl to interact with a cmdr daemon for diagnostic and testing purposes, this wiki documents how to do such a thing.

The HTTP server that is parsing these HTTP requests lives at: [lib/cmdr/cmdr_http.rb]

How to confirm that cmdr is running

One way to check that the curl daemon is running to curl localhost:1412

$ curl username:password@localhost:1412/devices
{"devices":["Extron","dvdplayer","projector",null]}

How to check the status of projector

You can check the value of any state_var by querying /devices/projector with the value you want to know about. So, for example, if you want to check if the projector's power field is on (true) send a GET HTTP request:

curl -XGET username:password@localhost:1412/devices/projector/power

Turning projector on or off

To turn a projector on send a post request to devices/projector/power

curl -XPOST -d '{"value": true}' username:password@localhost:1412/devices/projector/power

To turn a projector off send a post request to devices/projector/power

curl -XPOST -d '{"value": false}' username:password@localhost:1412/devices/projector/power