Exec binding issue - Dietpi

Hello everyone,

I would like to ask some help.

In my openhab I have added the Exec bindig and I would like to use it to start a browser when the system is ready. exec.whitelist location: /etc/openhab/misc/exec.whitelist

The .sh file location that I want to use /home/dietpi/OpenHAB.sh

When I try to run the .sh with exec bindig I got an error that its not in the whitelist. In the whitelist file I have added the /home/dietpi/OpenHAB.sh. What can be the issue ?

Most likely that you didn’t enter the path correctly, or you modified the wrong file. I’m pretty sure that the whitelist works as intended, or nobody would be able to use the binding.

Paste the contents of your whitelist file and paste the exact error from the log, maybe somebody can spot the problem.

Another thing…
/home/dietpi/ is most likely a folder with limited access for the openhab User (the one which openHAB is running).
If you want to start the script as user dietpi, the correct call would be

sudo -u dietpi /home/dietpi/OpenHAB.sh

BUT…
You’ll have to ensure, that the user openhab is allowed to call the command as user dietpi without password.
So edit the sudoers file (use visudo to prevent errors):

sudo visudo

and add the correct commandline (first line is already in the sudoers file)

root           ALL = (ALL:ALL) ALL
openhab        ALL = (dietpi) NOPASSWD: /home/dietpi/OpenHAB.sh

So user openhab is allowed to run the command as user dietpi without password.

Before using sudo as user openhab, you initially have to use sudo as user openhab manually (there is a message to affirm)
So login as user openhab without password:

sudo su - openhab -s /bin/bash

and issue the given command:

sudo -u dietpi /home/dietpi/OpenHAB.sh

and after affirmation the script should be executed successfully.

Finally, copy the exact command to whitelist and exec thing.

Hey,

so this is the error that I got:

Time
16:06:01.438
Timestamp
Apr 13, 2026, 2:06:01 PM
Level
WARN
Logger Class
org.openhab.binding.exec.internal.handler.ExecHandler
Message
Tried to execute 'sudo -u dietpi /home/dietpi/OpenHAB.sh', but it is not contained in whitelist.

What is the content of the whitelist file?

In the /etc/openhab/misc/exec.whitelist I have added the sudo -u dietpi /home/dietpi/OpenHAB.sh

Restarted after adding the line?? Whitelist is only reloaded after restarting

Also double check that the line in the whitelist exactly matches character for character the command entered into the Exec binding config. All the %2$s and other special stuff that you’d include on that line as arguments must also be in the line on the whitelist.

Given your error the line in the whitelist must be exactly

sudo -u dietpi /home/dietpi/OpenHAB.sh

I don’t know if white space matters but I recommend copying exactly what you’ve entered into the Exec binding config and then pasting is as it’s own line in the whitelist file.

A reboot as @milo suggests didn’t use to be required, but it’s an excellent next step.

It would be easier to just have /home/dietpi/OpenHAB.sh in the whitelist and have the sudo command in that script.

Also you didn’t have the full path to sudo command either.

I have just started to use this binding and found it is easier to whitelist the script and then put all the “tricky” stuff in the script.

hey,

with this method I was able to use the exec binding.

To get the up to date exec.whitelist for working I used the touch /etc/openhab/misc/exec.whitelist command so I dont need to reboot all over again my rpi4 :smiley:

How did you end up getting it to work?
Did you just have the script in the whitelist or also have the full path etc of sudo in the whitelist?

The Exec binding whitelist typically requires an exact match, so even small differences like relative vs absolute path, or missing execute permissions,can cause this issue.

Try ensuring the script is executable (chmod +x /home/dietpi/OpenHAB.sh) and that the whitelist entry has no extra spaces or hidden characters. Also, restarting openHAB after editing the whitelist often helps apply the changes.