jneilliii / OctoPrint-TPLinkSmartplug

105 stars 57 forks source link

Shutdown Raspberry before switching off plug #53

Closed Tronnic closed 6 years ago

Tronnic commented 6 years ago

Hello, I'm running a Raspberry Pi 3B with Touchscreen & TouchUI. When I turn off the printer with my TP Link Plug the Pi goes down as well. This is causing some major issues for me, since sometimes my installation gets corrupted.

Is there a way to start a 30 second timer on the plug itself, so the raspberry can shut down successfully? When I control the Plug with my smartphone there is an option for a timer so it must be possible somehow.

Thank you a lot for this plugin. If the above works it would be really great!

jneilliii commented 6 years ago

Is your Pi powered from your printer's board? There are options for running system commands, so you could issue a sudo shutdown command to the pi, but once the pi is powered off it won't be able to send the command to the plug to power it off as octoprint will no longer be running. If you are powering your pi off the board then unfortunately none of the options I know of would work.

Tronnic commented 6 years ago

okay :-/ thanks anyway. I thought it might be possible to start an timer on the plug itself instad of telling it to power off, since its possible to start one directly within the app. screenshot_20180804-231744_kasa

jneilliii commented 6 years ago

Good point. I didn't think of that. Let me check into it and get back to you.

Tronnic commented 6 years ago

That would be amazing! Thank you <3

jneilliii commented 6 years ago

I think I have it worked out if you don't mind testing. Use the below url in plugin manager to install.

https://github.com/jneilliii/OctoPrint-TPLinkSmartplug/archive/0.9.6.zip

Once installed set your plug's settings to something like this, using your plug's IP of course.

image

The GCODE off delay is what will be used to send the countdown timer to the plug. Then in your end GCODE commands use @TPLINKDELAYOFF 192.168.0.130 and it should achieve the goal.

In the above screenshot that will automatically disconnect octoprint from printer, send a countdown timer to the plug telling it to power off in 60 seconds and then immediately run the shutdown command.

Tronnic commented 6 years ago

I tried my best to give it a shot but I couldn't make it do what I wanted it to do. When entering "@TPLINKDELAYOFF " into my end gcode (OctoPrint Settings > Printer > GCODE Scripts > After print job completes" the plug shuts down immediately after the print is done. Also this wouldnt be as nice since I would need to edit the end gcode everytime I want to enable or disable automatic shutdown.

When enterting into the plugin "Shutdown Printer" nothing happens. image

What I have done before (to kill power after print is done, after reaching 60° Nozzle temp, was this in the "Mode API" section of the Shutdown Printer plugin. image

jneilliii commented 6 years ago

Disable the shutdown printer plugin. That one always forces a M81 command.

jneilliii commented 6 years ago

I'm going to make some changes because I realized that when pressing the button it would still use the old methods but I want to make sure it's working.

Tronnic commented 6 years ago

I will try right now, give me a moment. :)

jneilliii commented 6 years ago

I just pushed an update that should work all around. I took out the custom gcode commands and embedded it in the previous on/off commands, so Shutdown Printer plugin should also work the way you had it prior using the api command. reinstall using the same url above for version 0.9.6. Because of some settings changes you will have to re-enter your plug information, and then enable the options like this.

image

Tronnic commented 6 years ago

YouTube Video: https://www.youtube.com/watch?v=PtHjfr2-nD0 YouTube

Works! Thanks for all the effort you put into it. I'm so happy now, hehe :)

jneilliii commented 6 years ago

Great news. I'll release the updated version in a bit.

frabbba commented 10 months ago

Hello guys, @Tronnic May I ask which type of TP-link plug you used for this purpose described above? I wanna do the same and looking for a known to be compatible plug. @jneilliii As I understood you are the developer of this plugin. Could you tell me please with which TP-LINK plug would this method work? Any TP-link would do the job? Thanks for the Feedback in advance! 🙂

jneilliii commented 10 months ago

Currently known compatible models are the HS100, HS103, HS105, HS107, HS110, HS300, KP105, KP303, KP115. Other Kasa app based devices may work. Tapo series devices will not work with this plugi

Tronnic commented 9 months ago

Hello guys, @Tronnic May I ask which type of TP-link plug you used for this purpose described above? I wanna do the same and looking for a known to be compatible plug. @jneilliii As I understood you are the developer of this plugin. Could you tell me please with which TP-LINK plug would this method work? Any TP-link would do the job? Thanks for the Feedback in advance! 🙂

Sorry for the late answer! I was using a TP-Link Kasa HS110 Plug. Still in use, still working since 2018! :-)