-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue running USER FUNC #619
Comments
User scripts have to be owned by a non-privileged user and the owner has to belong to the pijuice group. Check if user Openhabian belongs to the pijuice group and has numeric userid 1000.. |
My linux skills are not great, hopefully I have done this correctly! I don't know how to test "the sudo command without password is removed for user Openhabian" , so let me know what you need me to do. Thanks |
@Steve-I this all looks the way it should be.
|
This is all as expected. The user function needs to be executable. What is the output from |
Sorry, I made a mistake on my last post (now deleted) - still figuring out linux! I'll try again: The script does start with |
Permissions and executable script are fine. I suppose you have specified e.g. USER_FUNCn for the 'no power' event on the System Events tab and enabled it. |
I think I've solved it - the power needs to be off for ~ 9-10 sec before the No Power System Event is triggered. I was only removing for about 5 seconds - presumably there is some debounce in there? Out of interest, is it possible to pass an argument from the User Function to the script. For example, can the User Function be set to (for example) Thanks for all your help! |
You cannot pass an argument to a user function (as you noticed). |
That's great, thanks for the info. I still have one issue, which I think is with permissions. I have a script which is very similar to When I run it from the command line (as user openhabian, there is no user pi), it asks for a password. If I comment out the |
Yes. this is the thing I mentioned before:
Then you should be able to execute a |
Thanks for the response. A few more questions as I don't fully understand this! The shut down script doesn't work from PiJuice. When the User Func runs the script, it runs every part of the script except the final Shut Down command ( I also ran the script as user Openhanbain to test the script and discovered that it asked for the password at this final shutdown step (not surprising). This confirmed that sudo access is required for this command. Ultimately, I don't need the script to run as user Openhabian (I was just doing this to test the script), I want the PiJuice HAT to be able to execute the script. There is already the file Or, does the user Openhabian also need to have the ability to run sudo without password for the PiJuice to shutdown the pi? |
USER_FUNC user scripts are run as the owner of the script. |
That has solved it - thanks! BTW, is there a typo on the Software page (https://github.com/PiSupply/PiJuice/tree/master/Software) - should |
Thanks for catching the typo. It indeed has to be |
I have installed a PiJuice on a Raspberry Pi 3B+, and I am running Openhabian (openhabian-pi-raspios32-v1.6.2), an image file based on Debian with OpenHAB pre-installed (https://github.com/openhab/openhabian). I then installed the pijuice-base (openhabian does not have a GUI).
Using SSH to access the raspberry pi, I can run pijuice_cli and have access to the configuration software (status option shows it seems to be working). The issue I have is that the scripts I have set up for User Func do not run. So far:
I used chmod 777 to set the permissions of the python script (test.py) to rwxrwxrwx. It writes to a log file (/etc/openhab/pijuice_log.log) which has permissions rw-rw-rw-.
My hunch is that it might be a user or permissions issue. Openhabian does not have the default user of 'pi', if that makes a difference.
Any ideas on what to do next?
Thanks
Steve
The text was updated successfully, but these errors were encountered: