Cannot get exec binding to work [SOLVED]

I installed the exec binding for openhab2 but I cannot even get the simplest example to work.

I want to check if my Amazon Echo is online and as the Echo is not pingable and does not have any open ports I cannot use the network binding. Also I do have a DHCP server running on the same machine which is why I cannot use DHCP discovery. So I wrote a script which uses ARP to detect if the Amazon Echo is online. That script runs just fine with the same user account that is used to launch OpenHAB:

openhab@cubietruck:~$ /home/openhab/bin/device-online echo.home.lan
ON

I added a “Thing” entry to my .things file:

Thing exec:command:device-online-echo "Echo" [ command="/home/openhab/bin/device-online echo.home.lan", interval=60, timeout=5 ]

I added an “Item” entry to my .items file:

String network_device_echo_online "Online" <network> (group_location_livingroom) { channel="exec:command:device-online-echo:output" }

I added a “Sitemap” entry to my .sitemap file:

Text item=network_device_echo_online label="Echo"

I would expect that the entry in my sitemap would now just display “ON” as this is the output of the script. Unfortunately it just displays “NULL” instead. In the log file I don’t see any exceptions but I just get some weird warnings every minute:

2017-02-07 20:46:07.005 [WARN ] [.core.transform.TransformationHelper] - Cannot get service reference for transformation service of type REGEX
2017-02-07 20:46:07.016 [WARN ] [hab.binding.exec.handler.ExecHandler] - Couldn’t transform response because transformationService of type ‘REGEX’ is unavailable

As these warnings are repeated every minute, I assume they are generated by the Exec binding. Can anybody tell me how to fix this? I tried various transformations I found on this forum but none of them worked.

1 Like

Can you uninstall it and install the “legacy” Exec binding? It’s been working well for years!

Hmm, I guess I could give it a try. Never used the legacy exec binding, I just got started with OpenHAB2.

Based on the log message, it seems like the REGEX transformation is not available in your installation for some reason. The binding uses “REGEX((.*))”, by default if no other transform is specified.

I have no idea why you wouldn’t have the REGEX transformation. I recommend checking the installation status in the Paper UI. If it says it’s installed you might try uninstalling and re-installing it.

2 Likes

Thank you, thank you, thank you! That did the trick!

I installed OpenHAB2 from the release ZIP file and did the setup according to the “Getting Started” instructions. I wasn’t aware you had to install these transformations manually. I thought they were available out of the box. Now that you mentioned it, I actually discovered the “Transformations” tab in the Paper UI. After installing it, the exec binding now works properly!

4 Likes