Addon.cfg load market binding?

Installing market bindings automagically doesn’t work (yet) with addons.cfg, so I created the following rule to install them manually after each server start (which I just assume is always preceded by an openhab update):

rule "Systemstart"
when 
	System started
then
	[...]
	Thread::sleep(30000)
	executeCommandLine("/etc/openhab2/marketbindings.sh")			
end

Contents of /etc/openhab2/marketbindings.sh:

curl -X POST -H "Content-Type: text/plain" --data "id=market:binding-3670618" http://192.168.1.253:8080/rest/extensions/market:binding-3670618/install
curl -X POST -H "Content-Type: text/plain" --data "id=market:binding-3499123" http://192.168.1.253:8080/rest/extensions/market:binding-3499123/install

Here I add the eBUS 2.0 Binding and the Openhab Xiaomi Mi IO Binding, but this works with any binding.
Not very beautiful, but working!

Don’t forget to put the binding id in both the link and the submitted data & put in your own server’s IP.

EDIT: previously I posted a solution with installing the bindings directly via executeCommandLine and curl, but according to https://github.com/openhab/openhab/wiki/Samples-Tricks#how-to-use-the-lifx-beta-api-via-executecommandline-and-curl this would require loads of @@, which don’t look good and are quite confusing,
Another solution would be to use sendHttpPostRequest. The idea stays the same.

4 Likes