User Tools

Site Tools


shutdown

This is an old revision of the document!


Sovol SV06+ (mostly)

Klipper Shutdown


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.


For the experienced:

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.

What you need:

The files:

  • hs110_off.cmd: Sends a power off command to the HS110 wifi plug
  • hs110_on.cmd: Sends a power on command to the HS110 wifi plug
  • mks_poweroff.cmd: Sends a shutdown command to the KlipperScreen
  • shutdown_sv06.cmd: Shuts down the KlipperScreen, then powers it off using the HS110 wifi plug

Prepare the ssh key:

  • Start puttygen.exe
  • Select the “EdDSA” radiobox
  • Click the “Generate” button
  • Press the “Save private key” button
    • Confirm that there is no passphrase by clicking the “Yes” button
  • Give it a filename, e.g. printer.ppk
  • Click into the upper box and select its content
    (it should start with ssh-ed25519 followed by a lot of gibberish)
  • Open Notepad (or any other text editor), paste the content there and save it for later use, e.g. as “printer_pubkey.txt”
  • Start Putty.exe, enter mkspi (or the IP address of your KlipperScreen) into the “Host Name” edit field
    • Click on the “Open” button to connect
    • Enter “mks” as username
    • Enter “makerbase” as password
  • Copy the public key into ~/.ssh/authorized_keys:
    • Execute mkdir -p .ssh
    • Execute nano .ssh/autorized_keys
    • Paste your public key (the gibberish line saved into printer_pubkey.txt)
    • Press CTRL+X to exit
    • Press Y to confirm saving
    • Press ENTER to confirm the filename

Prepare /etc/sudoers.conf:

  • Execute sudo visudo
  • Append following line in the editor that just opened:
  • mks ALL=NOPASSWD: /sbin/halt, /sbin/reboot, /sbin/poweroff
  • Press CTRL+X to exit
  • Press Y to confirm saving
  • Press ENTER to confirm the filename

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

  • Replace the “192.168.1.60” with the actual IP address of your HS110 wifi power plug.
tplink_smartplug.py -t 192.168.1.60 -c off

hs110_on.cmd

  • Replace the “192.168.1.60” with the actual IP address of your HS110 wifi power plug.
tplink_smartplug.py -t 192.168.1.60 -c on

mks_poweroff.cmd

  • Adjust PLINKCMD to match your putty installation.
  • Adjust PLINKKEY to match your generated ssh key.
  • Adjust PRINTER to the name or IP address of your KlipperScreen device
@echo off

set PLINKCMD=c:\putty\plink.exe
set PLINKKEY=c:\putty\printer.ppk
set PRINTER=mkspi

%PLINKCMD% -i %PLINKKEY% -batch mks@%PRINTER% sudo poweroff

shutdown_sv06.cmd

  • Adjust PRINTER to the name or IP address of your KlipperScreen device
@echo off

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

rem doc: PRINT ON SAME LINE: "<NUL set /p =TextToDisplay"

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

<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
shutdown.1731513307.txt.gz · Last modified: 2024/11/13 16:55 by torte