Trick #23: How to control the PSU plugin

A lot of users requested me the support of the PSU control plugin in Printoid.

That’s possible natively with Printoid since the v9.05 (12/20/2017).

1/ With Printoid PREMIUM

There is a direct integration of the PSU plugin for the PREMIUM users only.

If the PSU plugin is installed on your OctoPrint server, you will get a new entry in the left side menu. The actual PSU state is indicated in the icon and the label. Simply click on this entry to toggle the PSU state.

Of course, a warning dialog will protect this feature.

2/ With Printoid PRO

You can control the PSU plugin from Printoid PRO by using the custom HTTP commands from the Commands Panel.

From the official github page of the PSU plugin project, you can find the API documentation to control the plugin from Printoid.

turnPSUOn
Turn the power supply on.

turnPSUOff
Turn the power supply off.

togglePSU
Toggle the power supply on/off.

getPSUState
Get the current on/off state of the PSU. Returns isPSUOn(boolean).

cURL Examples

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

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

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

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

For example, if you wanna create a new command “Toggle PSU” in Printoid:

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

Then, in Printoid:

  1. Create a new command and select “HTTP (cURL-like)”
  2. /api/plugin/psucontrol should be add to the command as the “command”
  3. POST should be selected as the HTTP method
  4. { "command":"togglePSU" } should be added to the command as the “argument”

3/ Special thanks

Advertisements

One thought on “Trick #23: How to control the PSU plugin

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s