Linking a switch to a string input

Hi,

I’m trying to link a switch to a exec-binding-command (string input only):
.things:

Thing exec:command:switch1 [command="sudo /opt/433Utils/send 11111 1 [[ %2$s = 'ON' ]] && echo '1' || echo '0'", interval=1, autorun=true]
Thing exec:command:switch2 [command=“sudo /opt/433Utils/send 11111 1 %2$s”, interval=1, autorun=true]

.items:

Switch Switch1OnOff “Switch1OnOff” { channel=“exec:command:switch1:input” }
String Switch2OnOff “Switch2OnOff” { channel=“exec:command:switch2:input” }

Switch1OnOff is created successfully but nothing happens if it is activated (also no errors in the logfile).
I changed Switch2OnOff to String, now everything is working if I set it to “0” or “1”.
But how to I get this running with a Switch?

For testing purpose I already simplified the command of exec:command:switch1 to just touch /tmp/%2$s, but it looks like the command is never executed.

I also searched the forum and saw a lot of posts suggesting a .sitemap file, but as far as i know they are not supported by PaperUI.

My last idea would be to create a String item and a Switch item for each hardware switch and connect both with a rule. But that would be a bit ugly, as I have to create a lot of dummy items.

Can you suggest me any way to link a Switch to a String input?

Have you tried returning “ON” and “OFF” from the Thing channel instead of “0” and “1”?

Hi steve1, thanks for your answer and your time.
I’m not sure if I got you point but I tried the following:

.things

Thing exec:command:switch3 [command="/tmp/test.sh %2$s", interval=1, autorun=true]

.items

Switch Switch3OnOff “Switch3OnOff” { channel=“exec:command:switch3:input” }

test.sh

#!/bin/bash

echo “data: $1” >> /tmp/test.log
echo “ON”

I also pre-created the /tmp/test.log with 777 rights.

And the command seems to be triggered: the logfiles contains a lot of rows like:

data:

==> %2$s does not get filled

But its not reproduce-able: i tried some other things and reverted everything back to the version above and couldn’t get it running.

I’ll investigate further this weekend…