Missing Rights in for GPIOS

Hello everybody,
I know the title sounds like an typical problem. But I am really confused. This is the current state:
.rules File: Owner is openhab, in the executeCommandLine() I call an python Script where GPIOS are set. The owner of that Script is also openhab

Now I changed in my Terminal to the openhab user and I called: python name/of/my/script.py. Everything works fine.

But when I call the script through an item, I get the error: No access to /dev/mem. The openhab User is already added to the GPIO Group btw.

I even set in visudo : openhab ALL=NOPASSWD: ALL but even that worked not

Has anybody an idea whats going wrong here? All I wanna do I just to call an .py script where I could set the GPIOS :confused:

Show the exact command you used in this test.

What is the owner and group of /dev/mem? On my Pi it is owned by root and a the group is kmem. If your’s is the same then you need to add openhab to the kmem group as well. I don’t think this is GPIO specific and probably has something to do with how the Python script was written. I could be wrong though.

Hello Rich! Thank you for your answer!
I made an stupid error, I forgot the sudo in my executeCommandLine. So now my executeCommandLine in my Rule looks like that:

executeCommandLine("sudo python /etc/openhab2/myScripts/gpioControl.py 12 0", 5000)

When I now set with visudo

openhab ALL=NOPASSWD: ALL

eveything wookrs fine! :slight_smile: But of course I know that this is no very safe. So I want to make only my Script to have root access with:

openhab ALL=NOPASSWD: /etc/openhab2/myScripts/gpioControl.py

But that does not work. :confused: So the question I have now is, what files or directories do I have write in my visudo that everthong is working.

Finally I got an solution for my Problem. This line made it:

sudo chown root.gpio /dev/mem && sudo chmod g+rw /dev/mem

I dont need no visudo. Everything works fine so far :slight_smile: