Exec Binding 2: no item exec anymore?

I used in my OH2 installation this simple syntax within items:

Switch USB_EG_Windfang_01 	"USB: Weihnachten"	<light>	(gUSB, EG_Windfang)	{exec=">[OFF:/home/pi/usbstrom.sh 0 f 1] >[ON:/home/pi/usbstrom.sh 0 o 1]"}

within the Shell-Skript I turn on/off a USB-controlled power outlet.

Since the last apt-get update, I get the exec-binding 2.0.0.201612010742 - and the item is changed via rule and the UI, but it doesn’t fire the action anymore.
openhab.log:

pre-update (turn the lights on at 6AM):
2016-11-30 06:00:00.050 [INFO ] [e.smarthome.model.script.Licht-Check] - Licht-Check: es ist noch dunkel draußen.
2016-11-30 06:00:00.094 [INFO ] [ab.binding.exec.internal.ExecBinding] - executed commandLine '/home/pi/usbstrom.sh 0 o 3'
post-update (same rule, same item):
2016-12-06 06:00:00.113 [INFO ] [e.smarthome.model.script.Licht-Check] - Licht-Check: es ist noch dunkel draußen.
...nothing more

the item-value itself changes accordingly.
Events.log:

pre-update (turn the lights on at 6AM):
2016-11-30 06:00:00.062 [ItemCommandEvent          ] - Item 'USB_EG_Windfang_03' received command ON
2016-11-30 06:00:00.116 [ItemStateChangedEvent     ] - USB_EG_Windfang_03 changed from OFF to ON
post-update (same rule, same item):
2016-12-06 06:00:00.139 [ItemCommandEvent          ] - Item 'USB_EG_Windfang_03' received command ON
2016-12-06 06:00:00.142 [ItemStateChangedEvent     ] - USB_EG_Windfang_03 changed from OFF to ON

Is there something I have to configure differently since the last update?

The exec binding works with Things now. Check the readme.

1 Like

Thanks for pointing me directly to the readme!
This is getting complicated! So as I understand it, for a switch, I need to define the thing with reference to the switch’s status (%2$s) and then the switch in items would fire the things action?
I came up with this, but getting errors…

.thing:
Thing exec:command:USBtest [command="/home/pi/usbstrom.sh 0 %2$s 1 ", transform="REGEX((.*?))", autorun=false]

.items:
Switch testUSB	"USB: test"	<light>	(gUSB, EG_Windfang)	{channel="exec:command:USBtest:run"}

But I get these WARNings in openhab.log:

2016-12-06 22:05:33.637 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'binder.things'
2016-12-06 22:05:33.742 [WARN ] [home.core.thing.binding.ThingFactory] - Could not create channel 'run' for thing type 'exec:command:USBtest', because channel type 'exec:running' could not be found.
2016-12-06 22:05:33.747 [WARN ] [.thing.internal.GenericThingProvider] - Could not create channel 'run' for thing 'exec:command:USBtest', because channel type 'exec:running' could not be found.

if I klick then in the UI on the switch, in events.log is shown as the Switch is for the click on, but then off again:

2016-12-06 22:06:11.883 [ItemStateChangedEvent     ] - testUSB changed from OFF to ON
2016-12-06 22:06:11.895 [GroupItemStateChangedEvent] - gUSB changed from OFF to UNDEF through testUSB
2016-12-06 22:06:11.898 [GroupItemStateChangedEvent] - gUSB changed from UNDEF to OFF through testUSB
2016-12-06 22:06:11.900 [ItemStateChangedEvent     ] - testUSB changed from ON to OFF

What’s going wrong here? :wink:
Thanks for help!

So I was playing around a bit with the bits of documentation and stuff - and I’m getting deeper into OH2’s understanding of configuration - but still lost… :confused:

In my case, I’d like to use an USB controlled power outlet (4 outlets). It works fine with the 1.9 exec-binding and I want to take this as a learning for 2.x bindings…
So, first: the Thing would be the outlet as is and the Items would be the four outlets. I guess, that’s so far the understanding of OH2 architectur, isn’t it?

So I wrote a Shell-script, which allows me with some arguments to control the outlets:
/home/pi/usbstorm.sh [device ID] [on/off/get] [outlet ID]

So in my understanding, I should provide one Thing, which controls the USB-outlet. And then I define Items, which then hand over the arguments to the Thing?

In my example “device ID” is a constant (as I only use one device), “on/off/get” would be transformed in o(=ON), f(=OFF) or g(=GET) for reading actual state of the outlet. “outlet ID” should also come from the item, but at present I don’t know how to pass this one over to the Thing.

So, if there’s someone who could help me out, please review my thoughts and push me further in the right direction. Thanks!

You could also define multiple Things if necessary.

I think you can only send one command string to the item. The status of the item (e.g. some string) will then replace the %2$s in the thing.

I would define a String item and then use mappings in the sitemap to set the string as wanted.

If this doesn’t help, maybe you would need to create some rules or scripts to put the string together…

You could test this:

Thing:

exec:command:testoutlet [command="/home/pi/usbstorm.sh %2$s", interval=0, timeout=10, autorun=false]

Item:

String Test "Test" {channel="exec:command:testoutlet:input"}

Sitemap

Switch    item=Test label="Test" mappings=["1 on 2"="ON", "1 off 2"="OFF"]

I hope I got it right!

Holy moly!
Why is this so complicated? :fearful:

ok - I’ll get through this.

  1. After saving the .Thing file, I get the following:
2016-12-10 14:21:56.493 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'binder.things'
2016-12-10 14:21:56.579 [WARN ] [home.core.thing.binding.ThingFactory] - Could not create channel 'run' for thing type 'exec:command:USBtest', because channel type 'exec:running' could not be found.
2016-12-10 14:21:56.585 [WARN ] [.thing.internal.GenericThingProvider] - Could not create channel 'run' for thing 'exec:command:USBtest', because channel type 'exec:running' could not be found.
  1. after opening the UI and triggering “ON” or “OFF”, I get:
2016-12-10 14:25:00.311 [WARN ] [thome.io.rest.core.item.ItemResource] - Received HTTP POST request at 'items/testUSB' with an invalid status value '1 on 2'.
2016-12-10 14:25:02.829 [WARN ] [thome.io.rest.core.item.ItemResource] - Received HTTP POST request at 'items/testUSB' with an invalid status value '1 off 2'.

I changed the .sitemap to Switch item=testUSB label="USB Test" mappings=[1="ON", 0="OFF"], but:

2016-12-10 14:26:22.745 [WARN ] [thome.io.rest.core.item.ItemResource] - Received HTTP POST request at 'items/testUSB' with an invalid status value '1'.
2016-12-10 14:26:25.346 [WARN ] [thome.io.rest.core.item.ItemResource] - Received HTTP POST request at 'items/testUSB' with an invalid status value '0'.

I changed .sitemap again, to get something over to the thing: Switch item=testUSB label="USB Test", but:

2016-12-10 14:28:04.176 [INFO ] [ome.core.thing.internal.ThingManager] - Not delegating command 'ON' for item 'testUSB' to handler for channel 'exec:command:USBtest:input', because thing is not initialized (must be in status ONLINE or OFFLINE).
2016-12-10 14:28:04.177 [INFO ] [ome.core.thing.internal.ThingManager] - Not delegating update 'ON' for item 'testUSB' to handler for channel 'exec:command:USBtest:input', because thing is not initialized (must be in status ONLINE or OFFLINE).

So I guess the ERROR from above leaves the thing UNITIALIZED?

But my question would be: Why “input” and not “execute” in the item-definition? I don’t get the purpose, sorry…

Did you update openhab2 to the latest version? There was a bug in the Exec binding. Then try again!

ok, i did the update and now have:

174 | Active   |  80 | 2.0.0.201612091712    | Exec Binding

still got the error:

2016-12-11 10:49:36.902 [WARN ] [home.core.thing.binding.ThingFactory] - Could not create channel 'run' for thing type 'exec:command:USBtest', because channel type 'exec:running' could not be found.
2016-12-11 10:49:36.933 [WARN ] [.thing.internal.GenericThingProvider] - Could not create channel 'run' for thing 'exec:command:USBtest', because channel type 'exec:running' could not be found.

So, I’m giving up for the time being. I wrote some rules, so if the item switches, the rule kicks in and sends the exec-command:

if(USBtest.state == OFF) { executeCommandLine("/home/pi/usbstrom.sh 0 f 1") }
if(USBtest.state == ON) { executeCommandLine("/home/pi/usbstrom.sh 0 o 1") }

not very pretty, but works…

btw: I hope, the 2.0 KNX-binding will be easier to configure than exec. :anguished:

I have the same error, but the exec binding works for me.

Btw:
I saw that your Thing should have autorun=true (means it will run if you change the input).
“input” is the string you hand over to the Thing (from the Item).
“execute” is not a valid option.

The binding seems still to be under development so maybe it will be easier and without errors some day…

1 Like

Found almost a day regarding how to made exec works finally get the solution from you, I get on/off works under you way.
I still got 2 issue here

  1. I tried to make label at BASIC UI shows the last/current status with below items with either ERR or - come out.
    String DenonPower “Power Is [%2$s]” {channel=“exec:command:Denon_Power:input”}
    is there anyway to show it?
  2. how can I able to transform the revert from exec? I have put PWON=ON and the other with no result in Paper UI, it shows undefined

I get it solved by look around here