Skip to content
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

Only reads GPIO when user is sudoer #76

Closed
ThierryDi opened this issue Dec 5, 2017 · 14 comments
Closed

Only reads GPIO when user is sudoer #76

ThierryDi opened this issue Dec 5, 2017 · 14 comments
Labels

Comments

@ThierryDi
Copy link

Hello,
Issue is the following: by default the GPIO is accessible only by sudoers, hence if the user running octopi is not a sudoer with "no password" (which is not very security friendly) the GPIO read doesn't work.
Regards,
Thierry

@vitormhenrique
Copy link
Owner

This is not an issue with the plugin, and there is nothing I can do about it.
The plugin uses RPi.GPIO library to access the GPIO, you can just fix the permissions to the memory and gpio folders to the user that is running the server. The standard octopi image works fine.

Check this for more information:

@ThierryDi
Copy link
Author

Hello,
After fixing the gpio access the test using the Adafruit example works with no sudo, thanks for the tip.
BUT the plugin still doesn't read the temp (says 0).
Log: 2017-12-06 18:32:04,196 - octoprint.plugins.enclosure - WARNING - An exception of type ValueError occurred on readDhtTemp. Arguments:
('need more than 1 value to unpack',)
I run a self installed octoprint instance, therefore the user is not pi, but this shouldn't matter,right?
Thanks in advance

@vitormhenrique
Copy link
Owner

It is not getting the temperature from the plugin, probably because it can not find the scripts, or the access for the files are not correct:

Check if the files were copied, the default installation would be something like this:
/home/pi/oprint/lib/python2.7/site-packages/octoprint_enclosure/getDHTTemp.py

It should not need to run as pi, but again, if you just flash the default image it's going to just work, I suggest doing that. If you don't want to to this, find the installation files, check that they are there, fix the permissions, test the scripts by using:

sudo python /home/pi/oprint/lib/python2.7/site-packages/octoprint_enclosure/getDHTTemp.py 22 4

Also, you can just add a simple LED to raspberry pi GPIO and test a simple output, to see if it's working.

@ThierryDi
Copy link
Author

ThierryDi commented Dec 6, 2017 via email

@vitormhenrique
Copy link
Owner

Actually it does not, it should automatically find the file where the plugin is installed:

https://github.com/vitormhenrique/OctoPrint-Enclosure/blob/master/octoprint_enclosure/__init__.py#L228

Enable the debug mode on the advanced part of the plugin, it will log where it thinks the files are and more info to trouble shoot. Reboot raspberry pi, send me the entire log after you start getting the errors again.

@ThierryDi
Copy link
Author

ThierryDi commented Dec 6, 2017 via email

@vitormhenrique
Copy link
Owner

I forgot that you need to manually change one line on init.py file

line 41 change it to false, save, restart, and do it again....

Just change using nano for example:

nano /home/YOURUSER/OctoPrint/venv/lib/python2.7/site-packages/octoprint_enclosure/init.py

@ThierryDi
Copy link
Author

ThierryDi commented Dec 6, 2017 via email

@vitormhenrique
Copy link
Owner

Just do a search and replace "sudo python" to "python" on this entire file....

@ThierryDi
Copy link
Author

ThierryDi commented Dec 6, 2017 via email

@vitormhenrique
Copy link
Owner

I'll create a "force sudo" checkbox on the advanced settings on following releases, if you uncheck it would fix issues like this by not trying to use sudo.
Also, if I update the plugin it would "break" your installation. So check for this box on following releases.

@ThierryDi
Copy link
Author

ThierryDi commented Dec 7, 2017 via email

@vitormhenrique
Copy link
Owner

I just finished re-writing most of the plugin and implemented this requested feature, tested 95% of the plugin.

If you want to test it out uninstall the current plugin, go to the plugin manager, select get more, and where it says "from URL" use the development branch:

https://github.com/vitormhenrique/OctoPrint-Enclosure/archive/dev.zip

More documentation here:
https://github.com/vitormhenrique/OctoPrint-Enclosure/tree/dev

I'll push this to production after more people test it out.

@d3arts
Copy link

d3arts commented Jul 1, 2021

Excuse me I have similiar problem with DHT11 - "sudo python" isnt working but "sudo python3" return temp and humidity. Changing init.py file and replace python to python3 will be helpfull?! Yes, IT WORKS! Thank you for advice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants