I’m currently integrating your excellent Bond Bridge Pro product into a whole of house automation based on OpenHab.
I am trying to send HTTP commands using the openhab http binding but am having some difficulty getting the syntax right for the http call.
Openhab doesn’t allow for a separate body so I’m not sure how to write the URL to incorporate the command body e.g. where to put and how to write {“argument”:3} at the end of the http://192.168.1.117/v2/devices/1234567/SetSpeed so that the url includes the command arguments.
Note that attempts with Postman succeed when using SetSpeed with a separate body for the arguments so the end-to-end is working
Thanks in advance
Regards
Ian Carson
P.S. A specific OpenHab binding for Bond might be a good idea
Bond API doesn’t support any way of encoding the body of the request into the URL. I guess you’d expect something like PUT http://IP/v2/devices/1234567812345678/actions/SetSpeed?argument=3 ? That’s something we do not support. However, just about any HTTP library should allow bodies in the requests… that’s standard REST API design.
In the end I did find an OpenHAB binding to Bond Bridge (the one by SDamiano as it turns out). It works very well - integrating status changes into the OH event system and passing commands as well.
It’s added as a separate jar file into /usr/share/openhab/addons on the server running openhab.
I just came across your post about sending a PUT request from OpenHAB with a HTTP body part. It’s possible.
First you need to create your Thing from a HTTP binding. Configure it and make sure in the advanced configuration the option Command method is PUT and Content type is application/json
Now create a channel and open its advanced configuration. There is no openHAB transformation that allows to send a HTTP body directly, you need to create a map. To do so create a file in your transformations folder (usually /etc/openhab/transformations) with the name of your choice and the .map extension. As an example let’s use light.map. Then put some content where you map the command to an output. i.e.:
ON: { LIGHT=1 }
OFF: { LIGHT=0 }
For more details refer to this documentation about maps.
Add your Command URL extension and finally in the Command transformation field put the value MAP:light.map
That’s it. Once your channel gets the command ON, the HTTP call with body { LIGHT=1 } will be sent to your device. If the command is OFF, the body will contain { LIGHT=0 }
Even dough you already solved you problem, I hope this information is useful at some other point for somebody.