Exec Binding: transform input value

Hello together,

currently I’m setting up a new openHAB 3 installation (to replace my current openHAB 2 setup) and I’m at the point where I need the Exec Binding: I have several devices in my home which I can control via a single command line application using different arguments, some examples are:

/usr/bin/app some_lamp_on
/usr/bin/app some_lamp_off
/usr/bin/app room_shutters_up
/usr/bin/app room_shutters_stop
/usr/bin/app room_shutters_down

So I’ve created an exec thing with the command /usr/bin/app %2$s and linked its input channel to a String item named App_Test. In the basic_ui sitemap I added it as Switch item=App_Test. When I enable and disable the switch I can see that the command is executed with the arguments ON and OFF respectively.

Now here comes my question: Is it possible to transform ON and OFF to e.g. some_lamp_on and some_lamp_off for the String (or Switch) item (without rule and with preserving the default switch look in the UI)? Or do I really have to add one exec thing for each element (lamp, shutters, …) and (shell) scripts to do the transformation? What’s the best solution for this problem? By the way, as suggested I’m using the new UI for the configuration so far.

Thanks in advance.

Exec binding does not provide ‘command’ transformation features.
The idea is, since the input is a string, you do that yourself before submitting your command to exec.

You might do that via rule.
In your UI example, you might do it directly in the UI, have poking buttons send “bananas” or whatever instead of ON.
In a sitemap, you could use mappings=[ ]

What do you mean with “poking buttons”? When adding mappings to the sitemap the “switch look” gets replaced by “named buttons”, while the arguments passed to the command are still ON and OFF instead of some_lamp_on and some_lamp_off:
Switch item=App_Test mappings=[ON="some_lamp_on", OFF="some_lamp_off"]

Adding a rule for each item would certainly work, but it takes a lot of effort. With the Exec Binding 1 this was a one-liner along with the item definition, isn’t there a comparable simple solution?

Yes, it is restrictive in style.

Because that’s what you asked for.
The widget might be Switch but you’ve linked it to a String Item, send it what you like
mappings=["some_lamp_on"="banana", "some_lamp_off"="apple"]

Mappings takes the form of command, display text. The command has to suit the target Item, not the widget.

Don’t do that then, write one rule to handle many Items.

when
   Member of someGroup received command
then
   execItem.sendCommand(triggeringItem.name + ", " + receivedCommand.toString)

If you’re going to do it that way, you may as well use executeCommandLine() in your rule. You don’t have to use Things if you find them so inconvenient.

Ok thanks, it works that way, but I dislike the style.