Exec Binding Python Script

Hi,
I’m trying to start a python script with exec command.
I have openhabian on my raspberry pi 3 and Version 2.5.10 running.
I installed the Exec-Binding via Paper UI

First I added a things in a new *.things file:

Thing exec:command:intertechnoB1 [command="/usr/bin/python /etc/openhab2/services/senditgw433.py B 1 %2$s", interval=0, timeout=5, autorun=true]

And I added a item:

String Deckenlampe "Deckenlampe" <light> {channel="exec:command:intertechnoB1:input", autoupdate="true"} 

sitemap:

Switch item=Wohnzimmer_Deckenlampe mappings=[ON="ON", OFF="OFF"] 

When I tried to start it I got en error with the whitelist and I added the command to the whitelist.

Tried to execute '/usr/bin/python /etc/openhab2/services/senditgw433.py B 1 %2$s', but it is not contained in whitelist.

Then I got en error with RegEx Transformation an I added the RegEx to my addons.

Now I have no error but nothing happens.

I testet the command as openhabian@openhab and it worked:

/usr/bin/python /etc/openhab2/services/senditgw433.py B 1 on

So adding the user openhab to the sudoers with no password should help.

sudo visudo -f /etc/sudoers.d/010_pi-nopasswd

Adding following lines

openhab ALL=(ALL) NOPASSWD: ALL

Then I tested as openhab@openhab:

sudo su - openhab -s /bin/bash

also this works in the shell.

Now I have no Idea. Any other ideas?

Try without exec-binding:

executeCommandLine("/usr/bin/python /etc/openhab2/scripts/my_script.py update", 10000)

thx a lot.
I have tested this execute Command and it works!
I had to create a rule for that or is there an other way to use “executeCommandLine” ?

I put these two lines to the whitelist:

/usr/bin/python /etc/openhab2/services/senditgw433.py B 1 on
/usr/bin/python /etc/openhab2/services/senditgw433.py B 1 off

And I added these 2 rules:

rule "Deckenlicht aus"
when
    Item Deckenlampe received command ON
then
    executeCommandLine("/usr/bin/python /etc/openhab2/services/senditgw433.py B 1 on", 1000)
end

rule "Deckenlicht an"
when
    Item Deckenlampe received command OFF
then
    executeCommandLine("/usr/bin/python /etc/openhab2/services/senditgw433.py B 1 off", 1000)
end

Now it works like I expected.

But does anybody know how to do it with this exec binding?

It is not necessary.

The command in the white list needs to exactly match the command as you have it defined in your thing, complete with the %2$s stuff. So it should be

/usr/bin/python /etc/openhab2/services/senditgw433.py B 1 %2$s

The whitelist is not used with executeCommandLine.

I couldn’t say why it’s not working with the Exec binding.

Thank you for your reply.
The solution with “executeCommandLine” works for me. And you are right it is not necessary to put them to the whitelist.

I checked the whitelist entry for the exec binding and it is exactly the same and it dosn’t work.
So I can uninstall exec-binding and RegEx.
I think it’s too complicated for a newbie.