From the moment I considered buying the Vera Lite, I had in mind to program some of the logic in Bash. Im not a programmer but have Linux knowledge so this is quite an easy language for me to setup most of the logic. The way I thought it would work is to make use of http requests with curl to read and operate devices.
But from what I have seen so far, I’m not yet over the moon using the luup requests. I’m getting errors when trying to switch devices on and off(about a service not found, which I copied exactly from the device details) and some other issues.
My question in general is, if I want to use bash/linux commandline, what is in yours opinion the best way to work. Using the http requests like I already tried or is there some other flavour API? I’m also planning to make my own dashboard in most probably HTML5 to have an easy “app” to kickoff scenes and read temperature. I’m not yet a big fan of the Vera app. It starts slow(10+ seconds) and I keep the “Congratulations, your vera is ready message” along side the message that I dont have any device connected. Obviously I do have some devices.
Im not looking to solve those issues, but like to have some advice on using bash and HTML5 to talk with the vera.
Shell scripting will get you part of the way there, but it’s ill-suited to processing the responses that you get back from your curl requests (which will be in JSON or XML). You’ll need an additional tool to extract the interesting bits from the response (such as the current state of a switch). Most of those tools will have their own domain-specific language; for instance if you use xsltproc you’ll need to learn XSLT. While that’ll work (I’ve done it) you’re approaching a tipping point where it’s probably easier to switch from bash+curl+xsltproc to (say) JavaScript or Perl or Python or C#, which could each cover the entire problem space in one language. It depends on your desire to learn another programming language. Since you already know bash, it’s not a huge leap to Python.
There isn’t any API other than the HTTP one that you’re already using. All existing access points, from the native UI to remote-control apps, use this HTTP API.
On a different note: If you post your code that produced the “service not found” error then we can help you to debug it.
Thanks for your answers. Saves me probably a lot of time. Python sounds Okay because of the smaller step up. JavaScript has an advantage since it can also be used for the web/html part of job. But I tend to find JavaScript a quite complex language with a steep learning curve. Especially when you use it occasionally. I’ll have to make a judgement here.
Later today I will post the details of the error I get. Im not able to reproduce from where I am at the moment.
The URL I use is this:
http://:3480/data_request?id=action&output_format=xml&DeviceNum=3&serviceId=urn:schemas-upnp-org:device:BinaryLight:1&action=SetTarget&newTargetValue=1
The response I get is:
error: no service/action
In the details of the zwave switch I read:
device_type urn:schemas-upnp-org:device:BinaryLight:1
id 3
Thats brilliant, and actually works. Thanks! My next question would be how to get the serviceID. Can you point me in the right direction?
Furthermore, do you have any general recommendation about what to read to get some understanding of the API? I already read some stuff at [url=http://wiki.micasaverde.com/index.php/Luup_Requests#actions]http://wiki.micasaverde.com/index.php/Luup_Requests#actions[/url]. Maybe thats the place to, maybe there is some more/better documentation.