Switching off power

Hi,

I looking for a solution to cut the power supply‘s connection to electricity after printing. I am using a plugin to shut down the raspberry pi after printing by activating it in the gui.

But, is it possible first to shut down the raspberry and a couple of minutes later cutting electricity using a Sonoff?

I know there is a sonoff-plugin, but I think it cuts power directly after print job is done without shutting down the raspberry.

Is there a plugin solution?
And, do I have to flash the sonoff with tasmota?

My TPLink plugin could do this with a combination of gcode triggers, system commands and countdown timer options.I never got around to incorporating the countdown timers option in the tasmota plugin.

1 Like

This is an interesting problem.

  • POST -> /api/system/commands/core/shutdown
  • Wait
  • Shutoff plug

Unfortunately, that takes the TPLink plugin itself out of commission. A cleaner approach is to combine this with a separate daemon.

  • TPLink plugin sends shutdown verb to daemon
    • Daemon then POSTs to OctoPrint shutdown API
    • Waits
    • Daemon then toggles off the TPLink device by proxy for the plugin

Like I said in my previous post, you can do this completely with the tplink plugin and it works fine without any special daemon, etc. The settings below for example would send the off command to the TP Link device instructing it to use the countdown timer built into those devices to power off the printer in 5 minutes. That basically acts as your daemon you mention. Then the system command before off delay triggers the shutdown command of the pi itself after 30 seconds, you just use the same command you would use in octoprint's system shutdown option. And it's all triggered by the gcode trigger options to automate after print completes. At least that's how I remember programming it to work, but honestly haven't gone back and looked or tested since some of the recent strip and energy monitoring updates.

image

1 Like

So, to be honest, I am looking for a solution for my Sonoff.

If that's the case then I could get my tasmota plugin to work for you I think, but would take some development time and you'd have to flash tasmota to it.

Wow, dude. That's got it covered, then.

Would be very great... I already flashed TASMOTA to some of my SONFFs.
Please keep us informed... would save energy.

@Blebbens, are you currently using one of my Tasmota plugins? If so, which one?

I found octoprint-tasmota.
But, I am still waiting for delivery of my Sonoff POWs R2.

Ok cool, that's my web based version control, the simplest to update. I just pushed some changes to the repository under a separate branch I was developing. If you install the plugin using the url below it should work for your use case with the settings in the screenshot below the link.

https://github.com/jneilliii/OctoPrint-Tasmota/archive/0.8.6.zip

The settings above will basically react to a gcode command of M81 192.168.0.103 1 that you put in your end gcode settings of your slicer or in octoprint's gcode scripts section for after print job completes. The system command will be scheduled to run 30 seconds after which will power off the pi, and then finally the backlog command is used to tell the tasmota/sonoff device to power off in 5 minutes.

Hold off on installing. I just realized that the gcode triggers aren't running the system commands, so will need to adjust that in code. Guess that's a change I did in one of my other power related plugins. Will let you know when it's ready.

Ok, it's all set now. I added the system commands to the gcode processing loop and tested on my windows dev machine and it seems to be working as expected. Let me know.

Okay, I have to change your IP to my sonoff's IP, right ?

So, I found your Octoprint-tasmota-plugin in the official repository and installed it yesterday. I read the description and thought this plugin is able to shut down the power after shutting down the raspberry.

But, now I understood I have to deinstall the plugin for using your URL ?!

You can just install from that url and it will upgrade the version number. Yes, you use your device's ip address.