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

Add getPSUState API Command #34

Closed
kantlivelong opened this issue May 24, 2017 · 7 comments
Closed

Add getPSUState API Command #34

kantlivelong opened this issue May 24, 2017 · 7 comments

Comments

@kantlivelong
Copy link
Owner

No description provided.

kantlivelong added a commit that referenced this issue May 24, 2017
Add getPSUState API Command (#34)
@xoniq
Copy link

xoniq commented May 30, 2017

Tried this one command line, got this response:

curl -s -H "Content-Type: application/json" -H "X-Api-Key: XXXXXXXX" -X POST -d '{ "command":"getPSUState" }' http://XXXXXXXXXXX/api/plugin/psucontrol

<title>500 Internal Server Error</title>

Internal Server Error

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

The turnPSUOn and turnPSUOff is working however.

@kantlivelong
Copy link
Owner Author

@xoniq could you provide the octoprint log files?

@xoniq
Copy link

xoniq commented May 30, 2017

The error in the log:

AttributeError: 'PSUControl' object has no attribute 'isPSUon'

I did install this one:
https://github.com/kantlivelong/OctoPrint-PSUControl/archive/additional_api_commands.zip
So that should be alright.

Full stack trace:

2017-05-30 20:34:49,675 - octoprint - ERROR - Exception on /api/plugin/psucontrol [POST] Traceback (most recent call last): File "/home/pi/oprint/local/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/home/pi/oprint/local/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/home/pi/oprint/local/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/home/pi/oprint/local/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/home/pi/oprint/local/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/home/pi/oprint/local/lib/python2.7/site-packages/OctoPrint-1.3.2-py2.7.egg/octoprint/server/util/flask.py", line 1106, in decorated_view return flask.ext.login.login_required(func)(*args, **kwargs) File "/home/pi/oprint/local/lib/python2.7/site-packages/Flask_Login-0.2.2-py2.7.egg/flask_login.py", line 637, in decorated_view return func(*args, **kwargs) File "/home/pi/oprint/local/lib/python2.7/site-packages/OctoPrint-1.3.2-py2.7.egg/octoprint/server/api/__init__.py", line 99, in pluginCommand response = api_plugin.on_api_command(command, data) File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint_psucontrol/__init__.py", line 388, in on_api_command return jsonify(isPSUOn=int(self.isPSUon)) AttributeError: 'PSUControl' object has no attribute 'isPSUon' 2017-05-30 20:34:49,682 - tornado.access - ERROR - 500 POST /api/plugin/psucontrol (127.0.0.1) 23.53ms

@kantlivelong
Copy link
Owner Author

Ah I see. Doh!

Can you uninstall and reinstall using the URL then try again?

@xoniq
Copy link

xoniq commented May 30, 2017

Will do it as soon as my print is finished. Should be within the hour.

Edit: Lol, just a capital character fault? 🤣

@xoniq
Copy link

xoniq commented May 30, 2017

Success:

{
  "isPSUOn": 1
}

Thank you for the quick support.

@kantlivelong
Copy link
Owner Author

@xoniq Thanks for testing 👍

I've made one additional (and hopefully final) commit to return true/false instead of 0/1 for getPSUState to conform with JSON standards.

kantlivelong added a commit that referenced this issue Jun 27, 2017
Add getPSUState API Command (#34)
@kantlivelong kantlivelong removed the todo label Jul 5, 2017
kantlivelong added a commit that referenced this issue Sep 17, 2017
Add getPSUState API Command (#34)
Set initial state of the switching GPIO accordingly (#40)
Add Pseudo On/Off G-Code Switching (#26)
Added M106 to autoOnTriggerGCodeCommands defaults (#45)
Move static power off dialog from jinja2 template to js (#46)
Change power off dialog message
Add invert and pull-up/down options for Sensing (#39)
Add support for sensing via system commands
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants