EXEC binding migration from 1.8 to 2.x


I’m migrating my openHAB 1.8 to 2.x

Could you help me with this?

Switch  TELPosition "Tel Position" <television> { exec=">[ON:curl -s http://192.168.5.x:xx/...cmd=abc] >[OFF:curl -s http://192.168.5.x:xx/...cmd=xyz]" }

In other examples I’ve seen the “.things”, but it’s not clear how to split the two different command (switch ON/OFF)

Thank you!

The 2.x version of the Exec binding works completely differently from the 1.x version. It is a complete rewrite, not just a simple port.

So the first question is why do you want to move to the 2.x Exec binding? There is nothing that forces you to do that.

The second question is why are you not using the HTTP binding? There is no reason to have to drop to the exec to make a simple http get request with no body and you don’t care about the results. and in fact the syntax is almost identical:

{ http=">[ON:GET:http://192.168.5.x:xx/...cmd=abc] >[OFF:GET:http://192.168.5.x:xx/...cmd=xyz]" }

The Exec 2.x binding does not support this sort of construct as cleanly as the 1.x binding does. There are a number of approaches you can take but they will all involve additional Items and Rules. One such approach is to use a Proxy switch Item and in the Rule sendCommand the appropriate “cmd=abc” part of the command to a String Item lined to the input channel on the Thing. The Thing itself will be something like:

Thing exec:command:telposition [command="curl -s http://192.168.5.x:xx/...%2$s", autorun=false]

I believe that sending a command to the Item linked to the input channel will trigger the script to run. If not, you will need to link a Switch Item to the run channel and send an ON command to that Item from your Rule.

Another option also requires a Proxy Item but will require two Things, one that gets called for ON and another called for OFF. Then in your Rule that triggers on the Proxy Item you sendCommand to the proper Item linked to the run channel for the Item to execute.

Hello Rich!

I appreciate your great work. Thank you to the openHAB team!

I’ve chosen to use 2.x binding because I’m not sure if the olds are still maintained

You are right,
thank you for this tips!

Best regards