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 togglePSU API Command #33

Closed
kantlivelong opened this issue May 18, 2017 · 16 comments
Closed

Add togglePSU API Command #33

kantlivelong opened this issue May 18, 2017 · 16 comments

Comments

@kantlivelong
Copy link
Owner

No description provided.

@yschroeder
Copy link

yschroeder commented May 24, 2017

Yes, please! I want to build a keypad that issues API commands and I want to have a button that toggles power. However, I neither found a way via the API to get the current PSU status nor is this toggle option available.

@kantlivelong
Copy link
Owner Author

@yschroeder Yeah status makes sense too.

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

@yschroeder I've added both API commands to the additional_api_commands branch if you want to test it out and let me know how it goes.

Added:

  • togglePSU - Toggles supply on/off. No return data
  • getPSUState - Returns isPSUOn value(0/1) as a JSON.

@yschroeder
Copy link

Actually, I have no idea how to use a plugin that is not installed via the integrated GUI. Can you give me a hint on where to find this info?

@kantlivelong
Copy link
Owner Author

  1. Uninstall the existing plugin.
  2. Use the following URL in the plugin manager. (See example below)

URL:

https://github.com/kantlivelong/OctoPrint-PSUControl/archive/additional_api_commands.zip

image

@xoniq
Copy link

xoniq commented May 30, 2017

I will try it today. Yesterday mounted a ATX PSU to it, and turning it on and off goes just fine using the lightning icon. Will try it using the API.

@xoniq
Copy link

xoniq commented May 30, 2017

I'm testing it remotely, don't know I am doing it wrong.
Is this the right way to call it?

/api/turnPSUOff

@kantlivelong
Copy link
Owner Author

See #21

@yschroeder
Copy link

I've tested it now. togglePSU works as expected, thanks for that!

However I can't get the getPSUState to work. Is it a POST or a GET? Shouldn't it be a GET on /api/plugin/psucontrol/PSUState and then return a json object? I tested some variations but can't get the right response back. Please give a hint on how to use this.

@kantlivelong
Copy link
Owner Author

It should be a POST that returns json data but I haven't tested it as I don't have a working environment at the moment.

@kantlivelong
Copy link
Owner Author

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

@yschroeder
Copy link

That curl command returns a 500 error.

@xoniq
Copy link

xoniq commented May 31, 2017

@yschroeder

Remove plugin and add again via the same url. Yesterday they fixed it in a new commit based on my log. (See the other issue)

@yschroeder
Copy link

Getting the status works as described for me after installing again.

I would like to see both features getting deployed to release. For now I will keep using the plugin from the zip file.

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
@gurusonwheels
Copy link

plugin url does not work . i get 404

@kantlivelong
Copy link
Owner Author

@gurusonwheels its in devel now.

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

4 participants