How to make printer with octoprint available to be turned on, on command?


What is the problem?
I don't want to leave my printer on, all the time. I would like to make some kind power switch for it, but controlled and used automatically when I want to print something/ and killed when print is over

What kind of electronic master switch should I use, to make it possible for octoprint to turn on/off the printer and raspberry itself? Is it possible? i assume I need some kind of special cord?
How would I connec to it then? How to turn it on from asleep mode? is there any mode like this available for octoprint?

Additional information about your setup (OctoPrint version, OctoPi version, printer, firmware, octoprint.log, serial.log or output on terminal tab, ...)
I have newest octoprint, and prusa i3 mk3


in my setup, I have a AVM Fritz!DECT power switch.
With a little shell script I can switch the power state of this.
And this script is available in my octoprint system menu.

But for this setup you need (as far as i rembemer) as Fritz!Box also. An alternative variant would be a WLAN power swich (e.g. with Sonoff-Tasmota firmware).


You might need to leave the Pi on all the time, as WoL is not supported:

Unless you use a remote-controlled mains power switch.

For example.

Controlling the printer via relay controlled by the Pi is reasonably common, but not compatible with the way my Pi is powered, so I have not looked further.


I use a TP-Link HS100 SmartPlug. I can toggle it using the KASA phone app, the Alexa phone app and via Alexa skills by saying "computer, turn off/on the 3D printer", for example.


I use one of these:

I found a case that fits it too and it encloses the relays but permits access to the screw contacts.

It works great with Octoprint and permits me to control three devices.
I have my Tevo hooked to it, as well as two lights I can toggle on and off remotely.

I've been thinking about adding a third device.


There is a plugin you can use, and also search thingiverse for switching the printer on and off remotely. Gives complete instructions. Just have to use a relay board to switch the power, and as also said, you have to leave the pi on all the time.


I'm a fan of ITEAD's Sonoff WiFi switches,

flashed with firmware that uses WPA2 and MQTT (preferably over TLS), as they're cheap and line powered. You can run Mosquito on your RPi and there's a plugin for OctoPrint that lets you attach a power button in the interface to MQTT. Just make sure you wire them correctly, including ensuring an appropriate ground connection for the printer. If you prefer to avoid/can't handle a little wiring and using a TTL-to-USB serial cable to program the switch, a smart plug (for instance the one above or ITEAD's S20 or S31, below) might be a better option, though most require the use of a second- or third-party web service off in the cloud somewhere, which I prefer to avoid.


Thank you greatly for all of your answers, but I feel little lost. Some of you are saying that have done that, and can manipulate the power of the devide remotely, the other ones says that it can't be done, because raspberry needs to be powered all of the time?

I was thinking that, if I could plug in some kind of smart plug that connects to wifi - I can write a script (or ask someone for it), to have it turned on first in the attempt to start octoprint, then it would power the raspberry and printer. Would it be solution, or can you think about something similar that would make a job done?

To be honest - should, the raspberry pi be turned on 24/7? Is there any "asleep mode" for octoprint/the printer?


I have a xaomi wifi controlled multigang socket I turn the printer on and off via the mi app on my tablet.


I'm pretty sure that @jneilliii has already written one or more plugins which toggle these things off/on.

Turning OFF the Pi via a plugin is easy enough since OctoPrint is running and therefore plugins are running. Turning ON the Pi then is a cart-and-horse paradox: plugins aren't available if the Pi isn't powered. This is why I have two levels of control in mine.

My typical workflow:

  1. "computer, turn on the 3D printer" = Alexa uses the underlying TP-Link skill to turn on the printer's external power switch
  2. "computer, ask J.A.R.V.I.S. to shutdown the printer completely" = Alexa uses my app to tell OctoPrint to shutdown gracefully via its REST interface
  3. "computer, turn off the 3D printer" = Alexa uses the underlying TP-Link skill to turn off the printer's external power switch


OutsourcedGuru are you using 1 or 2 TP-Link Plugs with your setup. I have a Cyber Power Battery Backup that the RPI power adapter is plugged into, and my X3A is also plugged into a TP-Link, I have not set it up yet though. I would love to have my rig set the way yours is! Thank You...….


I have two of the HS100 version and one of the HS105. Both have the standard three-prong power plugs. The first one seems a little heftier.

The KASA phone app couldn't be simpler.

The Alexa phone app involves going into Settings and choosing Smart Home -> Add Device. The registration process involves using your Amazon ID. This is how all your Echo (and similar) devices know that you have this particular TP-Link and it will add it to your Alexa inventory, if you will.

I have one of the HS100 connected to a light in the living room, a.k.a. "light". The one associated with the printer I've named "my 3D printer". The one associated with the octo-proxy is the HS105 but I rarely toggle that one.

There are some photos here in a talk I did in San Diego on the subject.


Thanks for the shoutout @OutsourcedGuru. Yes, I've developed a tasmota plugin that will control sonoff devices as @supertaz linked flashed with tasmota firmware. I've created a TPLink plugin that will control the plugs @OutsourcedGuru mentioned, with recent updates for cleanly shutting down a pi prior to power off. I also have tasmota MQTT plugins that control tasmota devices via MQTT protocol. Another one that can control any type of switch that is controllable via Domoticz server and finally a beta Wemo plugin that can in theory work with Wemo plugs but have yet to find anyone to test it for me, so haven't released it to the plugin repository.


I just leave my pi on unless I go on vaycay or something (current image saved). Use the pi to auto control power to printer for controled startup in stages and shutdown using relays. Also, complete control and monitor via Printoid app. There's a ton of info on the interweb for whatever suits your needs. Just need to research and get the right plugins.


I've been trying to read all the topics related to powering off the printer and raspberry through a command, using relays or similar. In my case, raspberry is fed from the printers PSU and a sonoff switch powers the printer (and hence the raspberry)

I can do all I want manually and remotely, by using e.g. Printoid to shutdown the Pi and the sonoff interface to shutdown.

now, if I flash the Sonoff, I can from the Pi issue a (Sonoff) poweroff.

I see two problems with this:

  • when issuing the (Sonoff) poweroff, the Pi kills its own power before it can shutdown.
  • power down with a hot extruder is not recommended, as the extruder cooling fan will also stop.

So my questions are:

  • Is there a solution for operating a modified switch as discussed here that also cuts of power to the pi?
  • Do the shutdown procedures discussed here consider the extruder temperature in a safe manner?

Sorry if I missed possible answers on this in the forum, but I couldn't find any: my bad...


Grüezi @Ruedli!

Maybe this one is a step into your direction. Instead of controling an ATX PS, you also can use relays to control regual PS.
There is also a plugin that shuts down the RasPi at the desired nozzle temperature.


Grüezi wohl back to you @Ewald_Ikemann :slight_smile:

Thanks for looking into it and for your answers. I am also happy that there wasn't a quick solution that I had overlooked...

That looks indeed like one step. In fact, given the fact that a Sonoff switch is programmable and we flash it we could change the Arduino code and include this timer function. Maybe it is even there already, as the Sonoff in its natural form supports scheduled switch off. So you can program it to switch off in like a minute later...

Unfortunately, the ATX provides me another problem, as my printer is a Prusa MK3/MMU it runs on 24V.

The plugin for the temperature controlled shutdown, targets a TPLink device, might need to get that one, though I like seeing how much kWh my printer consumes, the Sonoff I currently use does that. Note that however it does not prevent shutdown when temperature is too high, but at least it schedules it.

Coming to think of it, I think it needs a script that ideally:

  • Registers a desired shutdown, either by a button, or from a remotely operated script.
  • Ensure that temperature is going down, by aborting an active print
  • Schedule a temperature 0 (in case no print was active, but it was e.g. preheating)
  • Wait till the temperature is lower then 50 C
  • Schedule a timed power off to the external relay device
  • shutdown the rpi

The plugin that you pointed out is pretty close and has most building blocks in it, be it there are still pieces missing as far as I can see.

If I take them step by step, in bold the problematic ones:

  • register shutdown: a button connected to a GPIO.
  • Script: you can run a python script to make the software believe a GPIO is triggered.
    - Schedule shutdown: can we abort an octoprint job from the command line? We could abort the whole octoprint, but then we cannot easily monitor the temperture... So it needs to specifically stop streaming print commands.
  • Schedule the temperature 0: send one Gcode for doing that.
    - Wait till temperature lower then 50C: the plugin could do that.
    - Schedule timed out power off to an external relay: your hardwareseems to do exactly that, but it would need to drive a relay.
  • shutdown rpi: piece of cake, sudo shutdown now

Maybe there is even something closer out there living in the unknown? :wink:


This one is tricky because you are powering the pi from the printer's board. I accounted for this in my TPLinkSmartplug plugin by utilizing it's built-in scheduling/timer/countdown functions. I might be able to do the same for a sonoff flashed with Tasmota, assuming Tasmota has that functionality, I'd have to investigate.


Here's the discussion on the TPLink-Smartplug side....


That plugin will actually work with a wide variety of devices, as long as their is an API available to use. It's worked with my Tasmota, Domoticz, and TPLinkSmartplug plugins. It was a plugin developed to add additional functionality to the ones I had programmed and then expanded to include generic api/web calls, etc. There's better documentation on the repository's page.