Table of Contents

THIS WIKI HAS MOVED!

ACTUAL LOCATION:

2025/01/21 11:53 · torte

https://torte71.github.io/InsideSovolKlipperScreen/shutdown.html

.








2025/01/21 11:53 · torte

Sovol SV06+/SV07+ (mostly)

Klipper Shutdown

Windows version


Do not simply power off the device by the switch.

Shut it down using either the web interface or the buttons on the KlipperScreen first.

Just powering it off can -and does- lead to damaged files.


Shutdown using scripts

I am using a set of batch files to power my printer on and off safely by first sending a “shutdown” command to the device via ssh (actually Putty's plink.exe) and then sending a shutdown command to my hs110 wifi power plug.

(Actually it is first checked, if the device is powered on (reacts to “ping”). If it does not respond, the hs110 is powered off immediately. Otherwise a “shutdown” command is issued to the device and the script waits until the device stops responding to “ping”. After an additional pause of 7 seconds, the hs110 is finally powered off).

These scripts are not limited to Sovol's KlipperScreen, they can be used with any hardware running linux (they do not even depend on klipper). Just make sure to a) adjust the variable PRINTER in mks_poweroff.cmd and shutdown_sv06.cmd to the name or IP-address of your device and b) adjust the variable USERNAME in mks_poweroff.cmd to the username on your device.

Requirements

The files

These 5 files need to be put into the same directory.

If nothing went wrong, you should now be able to shutdown and power off the printer by executing shutdown_sv06.cmd.

To power it on, execute hs110_on.cmd.


hs110_off.cmd

tplink_smartplug.py -t 192.168.1.60 -c off

hs110_on.cmd

tplink_smartplug.py -t 192.168.1.60 -c on

mks_poweroff.cmd

@echo off

rem === best practice is using a PLINKKEY instead of a cleartext PASSWORD ===

set PRINTER=mkspi
set USERNAME=mks
set PLINKCMD=c:\putty\plink.exe
set PLINKKEY=
set PASSWORD=makerbase
rem set PLINKKEY=c:\putty\printer.ppk
rem set PASSWORD=

rem === nothing should be changed below here ===

rem MKSPI: allow user "mks" to shutdown/reboot/halt (without "sudo" asking for a password):
rem        add following to /etc/sudoers.conf (run "visudo"):
rem        mks ALL=NOPASSWD: /sbin/halt, /sbin/reboot, /sbin/poweroff

set POWERCMD="sudo poweroff"

set OPTKEY=
if %PLINKKEY%x==x goto SETPW
set OPTKEY=-i %PLINKKEY%

:SETPW
set OPTPW=
if %PASSWORD%x==x goto LOGIN
set OPTPW=-pw %PASSWORD%
set POWERCMD="echo %PASSWORD%|sudo -S poweroff"

:LOGIN
%PLINKCMD% %OPTPW% %OPTKEY% -batch %USERNAME%@%PRINTER% %POWERCMD%

shutdown_sv06.cmd

@echo off

set PRINTER=mkspi

rem try to ping MKSPI
ping -n 1 -w 1000 %PRINTER% >NUL
rem bail out, if MKSPI did not respond
if errorlevel 1 goto smartplug_off

echo Shutting down MKSPI
call mks_poweroff.cmd

rem doc: PRINT ON SAME LINE: "<NUL set /p =TextToDisplay"
<NUL set /p =Waiting for MKS to shutdown
:pingloop
rem echo "." on same line
<NUL set /p =.
rem try to ping MKSPI
ping -n 1 -w 1000 %PRINTER% >NUL
rem bail out, if MKSPI did not respond
if errorlevel 1 goto did_shutdown
rem otherwise wait a second
ping -n 2 127.0.0.1 >NUL
rem then try next ping
goto pingloop

:did_shutdown
echo MKS has shut down.
echo Waiting additional 7 seconds...
ping -n 8 127.0.0.1 >NUL

:smartplug_off
echo Power off HS110 smartplug...
call hs110_off

Advanced: Passwordless login and shutdown using ssh key and visudo

Preparing the ssh key

Testing the ssh key

Preparing ''/etc/sudoers.conf''


Troubleshooting

Linux version

Linux versions of these scripts are available here.


Back to start