Exec-Binding and Setpoint

Hi,

I was searching for a way to use the exec-binding (openHAB 1.x) together with the setpoint element to create an easy way to show a value and modify it, e.g for volume control, temperture-set, etc.

The posts I found where always referring to a combination of number items and rules to make this work.
After some more research I found the following way which I would like to share:

Create php file and hand over parameters via argument $argv[x] to carry out the actual command for the change:

<?php
$Raum = $argv[1]; //FixedArgument1
$SollTemp = $argv[2]; //Variable Argument handed over by openHAB via %2$s
.....
?> 

Create number-item using the hand-over parameter %2$s used by openHAB:

Number TemperaturBadSollSet "Bad Soll Set [%.1f °C]" {exec="<[php /data/.apps/Controme/ContromeTempSoll.php Bad:5000:REGEX((.*?))] >[*:php /data/.apps/Controme/ContromeTempSet.php Bad %2$s]"}

Note that <[php file.php:5000:REGEX((.?))] is used to get the actual value of the parameter to be set and >[:php file.php FixedArgument1 %2$s] is used to execute the change command together with the newly set parameter by setpoint in the sitemap.

The actual sitemap element looks like this:

Setpoint item=TemperaturBadSollSet step=0.5 minValue=15 maxValue=26 icon="TemperaturSensor"

The syntax of openHAB to carry out this command is found under https://github.com/openhab/openhab1-addons/wiki/exec-binding and looks like this:

exec=">[<openHAB-command>:<commandLine to execute>]

Here the openHAB-command is simply replaced by a *.

Maybe it helps someone.

Cheers

Hi Björn,
thanks for sharing. I am currently implementing Controme in OpenHab2 and I have seen your solution on the Controme REST API website.

The exec binding in OpenHab2 is actually fundamentally different to OpenHab1.x Did you also figure out how to do this in Openhab2?

I have been able to read values via

var String json = sendHttpGetRequest("http://192.168.188.57/get/json/v1/1/temps", 60000)

and then extract the temperatures for each room. I have so far not been successful in setting temperatures using the same logic.

If you had anything on that I would be extremely thankful for some ideas how to do it (I have tried via things and channels but so far I only get error messages).

mroggi

Hi Matthias,
Unfortunately no.
I still have 1.x running. On a parallel server I currently try to install 2.x, however, I still use with the compability layer the exec 1.9 binding.
Sorry.
Cheers
Björn

Hi Björn,
sorry for bugging you. I still have problems implementing Controme on Openhab.

When I try

curl -X POST -F 'user=xxx' -F 'password=xxx' -F 'soll=30' http://192.168.188.57/set/json/v1/1/soll/3

from the command line I do not get an error message but also, the temperatur does not change. Any idea what is the problem with that statement?

I would be super helpful for help!!!

Hi Matthias,
no worries.
Change your input “http://192.168.188.57/set/json/v1/1/soll/3"
to
"http://192.168.188.57/set/json/v1/1/3/soll"
where “3” is the room ID which you will find in the jason array you get with
”$devicelist = json_decode(file_get_contents(“http://192.168.188.57/get/json/v1/1/temps/”), true);"
and “soll” is the temperature you want to set the room to.
Hope this helps.
Cheers