I tried to implement a new rule to execute a command using “executeCommandLine”.
I am using this already succesfully for other rules and commands, but now I have the following situation:
- using “executeCommandLine” with the relevant sh-file works well, if I run a very short command (less than a second).
- If I replace the command with the one I now need (python some_py_file.py), I can succesfully rule the sh-file manually
- But the file is not (fully?) executed by the “executeCommandLine” command within a rule in openhab.
Difference is, that this py-Script takes around 10-15 seconds to complete.
Might that be an issue? Already tried with the parameter DurationOfSeconds, which didn’t help.
Any ideas what I can try?
what does that mean ?
Store the return value of executeCommandLine in a variable and log it. This should give an idea if the command was aborted with an error message or executed successfully.
Thanks Wolfgang, will try logging output later!
I wanted to say that I am rather sure, that the rule is indeed triggering the sh-file, as it does successfully run a command when I exchange my python script within this specific sh-file.
Also there are no errors in the logs, thats why I think it triggers the file correctly.
But while running the sh-file from the command line directly does the job (unlocks my cupra formentor car after ca. 10 seconds), this doesn’t happen while being triggered from within the rule.
Will post result of the logged output later!
this can point to a permission problem as running the command on the command line directly is done with an other user than the openhab user which is used in the rule. Logging the returned value of executeCommandLine should provide more information.
okay, after 10 seconds I get following output:
File “/home/openhabian/unlock_cupra.py”, line 9, in
from aiohttp import ClientSession
ModuleNotFoundError: No module named ‘aiohttp’
as you mentioned may this be related to permissions?
Where is the module aiohttp installed ? Local for user openhabian only ( in user openhabian directory ) or global for all users ?
According to the error message it looks like it is the first case.
Thanks again Wolfgang,
think I can mark this as solved thanks to your help.
It was installed locally. I now reinstalled seatconnect + depencies via “sudo pip install …” and now the rule triggers everything as wanted.