Exec binding information

Hi everyone,
I’m trying to figure out how to use the exec binding.

Based on what I read so far, this is what I’m trying to achieve: send a netcat terminal command. The command is

echo "*2*2*16##" | nc 20000

I’ve first tried to run it manually from terminal sending

sudo -u openhab echo "*2*2*16##" | nc 20000

and everything works fine.

Now, this is what I did in OH:

  1. installed the Exec binding
  2. from the “things” page (paperUI), I added a new thing for the Exec binding, and set the command I want to execute. OH adds its channels (Output / Input / …)
  3. then I edited my items file adding
Switch swTestCmd {channel="exec:command:cmdRS_PT_StudioCortile_DOWN:run"}
  1. I finally created an entry in my sitemap file:
Switch item=swTestCmd mappings=[ON="Close"]

Now, if I click on the “close” button in my sitemap, nothing happens, and this is what I get in the log file:

2018-07-05 13:44:15.532 [ome.event.ItemCommandEvent] - Item 'swTestCmd' received command ON
2018-07-05 13:44:15.573 [vent.ItemStateChangedEvent] - swTestCmd changed from OFF to ON
2018-07-05 13:44:15.581 [vent.ItemStateChangedEvent] - exec_command_cmdRS_PT_StudioCortile_DOWN_run changed from OFF to ON
2018-07-05 13:44:15.602 [vent.ItemStateChangedEvent] - swTestCmd changed from ON to OFF
2018-07-05 13:44:15.620 [vent.ItemStateChangedEvent] - exec_command_cmdRS_PT_StudioCortile_DOWN_run changed from ON to OFF
2018-07-05 13:44:15.622 [vent.ItemStateChangedEvent] - exec_command_cmdRS_PT_StudioCortile_DOWN_lastexecution changed from 2018-07-05T13:34:38.602+0200 to 2018-07-05T13:44:15.606+0200

Can anyone tell me what’s the problem with my configuration?
Thanks :slight_smile:

Can you publish that too, please?

Here it is:


What does the openhab.log say?

mmm… I did’t noticed this before…Here it is:

2018-07-05 14:43:07.587 [WARN ] [hab.binding.exec.handler.ExecHandler] - Couldn't transform response because transformationService of type 'REGEX' is unavailable

What does this mean?

Try install the RegEx Transformation in Add-ons => Transformations and see if it helps.

Tried that…It still doesn’t work (though I don’t receive the log error anymore)

Can you create a Thing?

I have one ( copied from this community ) like this:

Thing exec:command:cpuTemp [
        // Command to execute
        command="cat /sys/class/thermal/thermal_zone0/temp",
        // interval time in seconds
        // should it run when input channel is changed
        // REGEX transformation to make 44007/1000 => 44.007
        // explanation for the regex
        // s/           - substitute
        // (.{2})(.{3}) - a number with 5 characters, split in two groups
        // /$1.$2/g     - returned value= first group, a dot, then second group, used to devide by 1000
        // alternative EXEC transformation with python 
        //transform="EXEC(python3 -c \"print(%s/1000)\")"

Then and item:

String System_Temperature_CPU_out { channel="exec:command:cpuTemp:output" }

And then a rule:

 rule "Convert String to Item Type"
    Item System_Temperature_CPU_out changed or 
    Item System_Temperature_GPU_out changed 
    val toUpdate = triggeringItem.name.toString.split("_out").get(0)
    postUpdate( toUpdate.toString , triggeringItem.state.toString )

It just works :slight_smile:

@rebzone maybe describe what you want to do. It could be that there is a better solution then using the regex binding.

I’m trying to find the best solution to make my Bticino roller shutters work as I want them to work :slight_smile:
I mean: there are 2 bindings that actually work, but the response to a command lags too much. When I use a single rs, it simply works, but when I try to control every single rs at once in a scenario (like “close all” or “half open”), the rs react after seconds, so I can’t set an accurate position.
I’d like to understand if it’s a binding related issue or if there’s something wrong in my system.

Since I came from Home Assistant, where I used some console scripts to control my rs like the one in the first post (echo “22*16##” | nc 20000), and everything was working perfectly, I wanted to reproduce the same environment.
If OpenHab can’t correctly manage my rs, I need to switch to another system :confused:

Maybe post your full bticino setup in a other question and ask it there is someone who has experience with this. Maybe they spot some problems.

For your exec try, I would say change the command to echo '*2*2*16##' | nc 20000, replace the " as i think this could make some problems.

Or try to make a whole file based setup.


 Thing exec:command:bticino [
            command="echo \"*2*2*16##\" | nc 20000",
            timeout=60 ]


Switch Test_Button
Switch Bticino_send { channel="exec:command:bticino:run" }
String Bticino_rsp { channel="exec:command:bticino:output" }


sitemap test label="Bticino"
    Frame label="Bticino"
        Switch item=Test_Button


rule "Bticino test sending"
    Item Test_Button received command 

      logInfo("Bticino", "Start sending data.")


      // Wait for the command to complete
      while(Remote_Send.state != OFF){

      logInfo("Bticino cmdline response", Bticino_rsp.state.toString.replaceAll("\r|\n"," ") )


Maybe this will get more info, why this does not work.

PS: all above may contain typos, this is not tested.

Hey folks … this not not what rebzone want to know …the question is what kind of return has the command run? And if know that how could we make a REGEX definition ??