Power On/Off 3D Priner W/ OctoPrint and SmartSwitch

by ShaiP in Workshop > 3D Printing

14499 Views, 31 Favorites, 0 Comments

Power On/Off 3D Priner W/ OctoPrint and SmartSwitch

Screenshot from 2016-04-25 23-35-11.png
Screenshot from 2016-04-25 23-35-22.png
61TUGc8HFwL._SL1500_.jpg

This is a simple guide which well help you setup a WEMO Insight Switch, $50 on Amazon http://amzn.to/26qdS91, (or any other WEMO Switch) controlled via OctoPrint's system menu to power your plugged in printer on or off.

The benefit of using the Wemo Insight switch is you get power usage reporting and direct control (more on this later)

Although this guide's for power cycling a printer, it could also be for LEDs or anything else you can plug into a smart switch. (I'm going to setup an LED switch in the future)

If you have something like the Samsung SmartThings SmartSwitch, http://amzn.to/1Wn7FGd, they don't allow direct API calls, easily that is, so the easy setup is using the IFTTT maker channel, https://ifttt.com/maker. In this case, you'd setup SystemEditor's command to CURL the maker channel a particular event. That event, would in turn signal your SmartThings Switch. Note that there is a delay here since IFTTT doesn't check every second. Hence the reason I went with the WEMO, for that immediate access.

Even simpler, but not covered here as it involves connecting to the PI's GPIOs is an enclosed Relay: http://amzn.to/1SKOSVU. This would allow you immediate power switching with a direct signal from the PI's GPIO using the GPIO cmd line tool. (I may do this later to simplify the setup. Downside is it requires the PI to be on, and offers no other software way other than in the PI to power off the machine.

SSH to OctoPrint

Screenshot from 2016-04-25 23-39-44.png

Start off by SSH'ing to your octoprint host. You can try the default pi@octopi.local. If this doesn't work, substitute the octopi.local for IP address.

Create/Edit the Script

Screenshot from 2016-04-25 23-38-56.png

use nano to create/edit the file we're calling wemocontrol.sh

Copy the Script

Screenshot from 2016-04-25 23-39-05.png
Screenshot from 2016-04-25 23-38-56.png

Copy the Wemo Control script from http://wemo.forumatic.com/viewtopic.php?t=5&p=5 and paste it into nano.

You could use just the CURL command here directly, but it's may more complicated and using this script makes interfacing with the wemo much easier!

Press ctrl+x to exit, then y to save and hit enter.

Now run: chmod a+x wemo_control.sh to make the script executable.

Before moving on to the next part. You need to find your WEMO's IP on your network. I did this by going to my routers attached devices list. Then one by one issuing the on command noted below to each IP, till I saw the printer turn on.

Now you can test the script with: ./wemo_control.sh [IP] GETSTATE

If that works you should see an ON/OFF state. Then replace the GETSTATE above with ON or OFF to test via command line.

Download System Editor Plugin

Screenshot from 2016-04-25 23-45-51.png
Screenshot from 2016-04-25 23-48-12.png
Screenshot from 2016-04-25 23-58-59.png

Download the System Editor plugin from the OctoPi repo: http://plugins.octoprint.org/plugins/systemcomman... Optionally install Editor Collection for a cleaner admin interface: http://plugins.octoprint.org/plugins/systemcomman...

Note that you can add/and should add the plugin directly from OctoPrint's plugin manager. You will likely have to restart OctoPrint for the plugin to show. SO DON'T DO THIS DURING A PRINT!

Create the OctoPrint System Command

Screenshot from 2016-04-25 23-35-34.png
Screenshot from 2016-04-25 23-35-54.png
Screenshot from 2016-04-25 23-35-45.png

Take the command from step 3 and enter it here for a "Printer On" and "Printer Off" commands. You can use the confirmation message on the off command as a safety measure so you don't accidentally power off the printer.

Test Via OctoPrint

Screenshot from 2016-04-26 00-01-19.png
Screenshot from 2016-04-26 00-01-09.png

You should now see the power on and off options in octoprint's system menu. Give them a try and you should see a confirmation like the screenshots.