rpi_WS281X-Unable to execute python script from rules file

I am trying to run a simple LED strand test on WS2812 LED strip attached to rpi 3B.

strandtest.py is located in the path /home/openhabian/rpi_ws281x/python/examples/strandtest.py .
when I run the file from the shell(oepnhabian) using the below command it works fine.

 sudo python3 rpi_ws281x/python/examples/strandtest.py

However when I execute through a rule as below, it errors.

rule "water level"
    Time cron "0 17 11 ? * ?"
   var output = executeCommandLine(Duration.ofSeconds(30),"python3","/home/openhabian/rpi_ws281x/python/examples/strandtest.py")
   logInfo("aquarium", output)


2022-06-14 11:17:01.435 [INFO ] [g.openhab.core.model.script.aquarium] - Failed to create mailbox device

: Operation not permitted

Traceback (most recent call last):

File “/home/openhabian/rpi_ws281x/python/examples/strandtest.py”, line 83, in


File “/usr/local/lib/python3.9/dist-packages/rpi_ws281x-1.0.0-py3.9-linux-armv7l.egg/neopixel.py”, line 100, in begin

raise RuntimeError('ws2811_init failed with code {0}'.format(resp))

RuntimeError: ws2811_init failed with code -9

I am guessing it may be because of lack of permission, but I have done the following to add permissions

openhabian@openhabian:~ $ sudo chmod +x /home/openhabian/rpi_ws281x/python/examples/strandtest.py
[sudo] password for openhabian:
openhabian@openhabian:~ $ sudo addgroup openhab spi
Adding user openhab' to group spi’ …
Adding user openhab to group spi
openhabian@openhabian:~ $ sudo chmod ugo+x /home/openhabian/rpi_ws281x/python/examples/strandtest.py

When you run it from the command prompt you use sudo. When you run it from executeCommandLine you don’t. Therefore the script is not running as root and it probably doesn’t have permission to access something it needs.

You’ll need to make sure that openhab is in sudoers.

How do I check that?