2022-02-24 12:06:30.699 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'power-1' failed: For input string: "sh: 1: /etc/openhab/scripts/sma3.py: not found
If I try this in command line, I got the same result. Only when I call it with user openhabian & python I got the expected result.
openhabian@openhabian:/etc/openhab/scripts $ sudo -u openhab "/etc/openhab/scripts/sma3.py"
sudo: unable to execute /etc/openhab/scripts/sma3.py: No such file or directory
openhabian@openhabian:/etc/openhab/scripts $ sudo -u openhabian python "/etc/openhab/scripts/sma3.py"
{"total": 16698301, "today": 2802, "spotacpower": 449}
The message is about a rule; not related to your Thing.
There’s your clue. openHAB does not run under user openhabian, it runs under user openhab, so you’ll have to grant user openhab permissions to the script file and any other resources it needs…
Thanks for your response rossko57.
When I changed the permissions and execute it via the openhab user I got errors on the import functions I use within the script. Could it be that those functions aren’t available for the openenhab user?
What is the correct syntax that I need to use for my Thing configuration?
There shouldn’t be any difference between OH2 and OH3.
In your call the leading python in front of the script can be left out in case:
a) shebang ( #!/path/to/python ) is used in the script’s first row ( this defines the script interpreter )
b) the script is readable and executable