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




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.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: SSH to OctoPrint

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.

Step 2: Create/Edit the Script

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

Step 3: Copy the Script

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.

Step 4: Download System Editor Plugin

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!

Step 5: Create the OctoPrint System Command

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.

Step 6: Test Via OctoPrint

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.

3D Printing Contest 2016

Participated in the
3D Printing Contest 2016

Home Hacks Challenge

Participated in the
Home Hacks Challenge



    • Indoor Lighting Contest

      Indoor Lighting Contest
    • Metal Contest

      Metal Contest
    • Make It Fly Challenge

      Make It Fly Challenge

    5 Discussions


    8 days ago

    I am trying to have your script working with a WEMO mini and unfortunately, it doesn't activate it in my .ssh session. After finding its IP address on my home network, I wrote down the command ./wemo_control.sh GETSTATE and... nothing. I had to CTRL+c out of the blinking cursor. Can you help please?
    update: just noticed that a plugin exists called OctoPrint-WemoSwitch .... I will try that...

    super fly

    2 years ago

    Do the TP Link plugs allow API calls?


    2 years ago

    Unfortunately the link to the script is broken as the host site has closed. Could you add a copy of the script code to the instructable?

    1 reply

    Reply 2 years ago

    I was able to find it here: http://moderntoil.com/?p=839

    I had troubles with the formatting when copy and pasting but I ended up finding a link near the bottom of the page that lets you download a copy of the file. Copy it over to your pi and then chmod it. Works great.


    3 years ago