Parameter Hand Over in Exec Binding

After many years of using OpenHab1 and carefully avoiding OpenHab2 because of the exec binding, I gave it a shot today.

Unfortunately I am already stuck after a couple of hours.

I want to run a php script which hand over a parameter. I hoped to use “things”, “items” and “sitemaps” in such a way that in things I would define the hand over parameter as %2$s in things and either in items or in sitemaps I would define this parameter to receive the status of an item (in this case a temperature).

Thing exec:command:Controme [command="php /etc/openhab2/extern/Controme/ContromeTemp.php  %2$s", interval=60, autorun=true]

I define the items as

String RT_Bad "Bad [%s]" {channel="exec:command:Controme:input", channel="exec:command:Controme:output, interval=1, autorun=true"}

However, I am stuck now, how I can hand over the argument (a string / “RT_Gaeste-WC”) within the sitemap.

Can someone maybe help me?
Please.

I only use paperUI & HabPanel, but what you’re asking is really easy.


By enabling Autorun, whenever the input is changed, %2$s passes the input value to the Exec command.

I have nothing in the Exec section other than %2$s because I enter the full command line statement into the input.

I hope this helps you.

Hi,

Thank you for your fast reply.
Unfortunately the input parameter does not change but is defined differently in individual positions in sitemaps.

Maybe I could not explain myself fully, so I try again:

I want to hand over a parameter one time (name of room) and this parameter shall be defined in sitemap or items. This parameter defines the room where I want to have the temperature from. However, the status of this room temperature shall be updated regularly.

Could I express myself?

Thank so so much.

Hi

I’m sorry, I don’t understand what you’re trying to achieve.

Your question implied that you wanted to pass an input to an script, via the exec binding.

Or are you trying to get the output of your script to display in your UI?

Yes, but also try to use things to reduce the number of lines to be programmed in OpenHab2.
Do you think this is possible?

Unfortunately you have already gone beyond my understanding.

I only have experience of the GUI side of openHAB2.

All I can tell you is that I harvest a value from a single OneWire sensor using a digitemp command in an Exec Binding Thing, and link the output to a string Item.

Thank you anyway. Can anyone else maybe help?

There is absolutely nothing preventing you from continuing to use the Exec1 binding.

You can’t link the same Item to both the Input and the Output Channel of the Thing. You need one Item linked to the input channel. Anything that Item gets set to will replace the %2$s in the command. The result from calling the script will be set to a separate Item linked to the Output Channel.

The interval and autorun parameters can only be defined on the Thing. You cannot define them on the link in the Item.

Then you must write Rules to pass these parameters to the Item linked to the Input channel. This will kick off the script and the result will be set to the Item linked to the Output Channel.

1 Like

Hi Rich,
Sorry for my late reply.
Thank you for your response.
I used your suggestion to write rules.
THX.
Björn