Exec binding - getting JSON data from a script


I’m trying to create an item that returns JSON data from a shell script (that I can then parse and put into other items).

String Test string exec="<[test.sh:5000]" }

which I thought would run every 5 seconds and put the JSON data into “Test”.

However in the logs I get:

19:20:07.673 ERROR o.o.m.i.i.GenericItemProvider[:350]- Binding configuration of type 'exec' of item \u2018Test\u2018 could not be parsed correctly.
org.openhab.model.item.binding.BindingConfigParseException: bindingConfig 'test.sh' doesn't represent a valid in-binding-configuration.

I assume I’m doing something dumb, but not clear to me what it is… any help would be much appreciated…

1 Like

Your Item definition has two errors. First of all you cannot have a space in your Item name. Second you are missing the open “{” in your binding definition. It should be:

String Test_string { exec="<[test.sh:5000]" }


apologies, the quote in my post was mangled. The actual text is:

String TestString  { exec="<[test.sh:5000]" }

… which triggers the error log above…

Hmmm. The error clearly indicates that the problem is in parsing of the exec binding string. What is weird is the \u2018 which is unicode for left single quote which I don’t see anywhere in the Item def you provide. Based on what you have here the error makes no sense.

The format, as shown looks correct. Maybe you have some characters in place that are not being rendered by whatever you are using to edit your Items file with.

The first thing I would try is to delete the Item definition and retype it in. Believe it or not I’ve had that work more than once for me over the years from shell script to C++ code. Make sure you are using either Designer or a basic text editor as well (vi, vim, emacs, pico, etc) to keep it from mucking with the text to make it pretty.

Many thanks for looking at this. I think I’ve found the problem.

I used nano to create a new test.items file and typed (not pasted) the following:

String Test_string { exec="<[/etc/openhab/configurations/test.sh:5000]" }

Still gave me the error (absent the unicode - so that must have been characters going awry as you suggested).

Then on a hunch I added a transformation:

String Test_string { exec="<[/etc/openhab/configurations/test.sh:5000:REGEX((.*?))]" }

It now works.

So, unless I am just confused, the problem seems to be simply that that wiki is wrong to say that the transformation argument is optional!