Help: Creating a Button to send Wake on Lan from OctoPi to Home PC?

What is the problem?
I want to use the SSH Tunneling through Spaghetti Detective to get to my OctoPrint when I'm away and would like the Pi to send a magic packet over LAN to turn on my PC when I'm away from my home wi-fi

What did you already try to solve it?
Researched online but haven't found any supporting documentation.

Logs (syslog, dmesg, ... no logs, no support) (3.8 MB)

Since I already have the tunnel to the OctoPi I thought I could put something in there to send this request or build a plugin if I have to. Just wanted to see if any other users have ever tried their hand at creating/doing something like this!

Is Spaghetti Detective using SSH tunneling to connect to your OctoPrint instance? That doesn't sound like something that would have been approved on the plugin repo during review.

In any case, if you can find the linux command to send the magic packet you could use Event Manager to do run it on specific events (ie, PrintStart, PrintFail, etc.). The other option would be using GCODE System Commands to run the command from a button you add using Custom Controls in config.yaml.

Whoops my bad I mixed up what I saw - it's SSL not SSH my bad :slight_smile:

I'll give that a try! Gives me something to start with. I'll update the thread if I find anything useful!

Hi. Did you manage to find a way to send a Wake On LAN packet to the PC?

No :frowning_face:

However, I did realize what @jneilliii is in the right direction, I just don't know the command to put into the config.yaml to send the WOL packet...

quick google search...

sudo apt update
sudo apt upgrade
sudo apt install etherwake
wakeonlan MAC-Address-Here
1 Like

So far this is about as far as I've gotten with commands and actions

I get the error pop-up when trying to select "System Update"


{"error":"Command does not define a command to execute, can't proceed"}

When I put the command in the action like

  - action: systemupdate
    command: sudo apt update
    name: System Update

I get:

{"error":"Command for custom:systemupdate failed: 500 Internal Server Error: Command for custom:systemupdate failed with return code 1:\n\nSTDOUT:\n\n\nSTDERR:\nsudo: no tty present and no askpass program specified\n"}

Not sure if I'm heading in the write direction or if I'm testing this correctly - I'm new to YAML and Linux.

separate issue to the original request, but the problem is that you're using sudo. that isn't allowed because you have to enter the password when running those commands. you could add a sudoers rule to allow passwordless running of the apt command, that is why sudo service and sudo shutdown work. this is the command that is run to support it on the octopi image.

echo "${BASE_USER} ALL=NOPASSWD: /sbin/shutdown" > /etc/sudoers.d/octoprint-shutdown

that's using variables though, so you might want to look at the file as an example.

cat /etc/sudoers.d/octoprint-shutdown

Something like this with pi as the username...

echo "pi ALL=NOPASSWD: /usr/bin/apt" > /etc/sudoers.d/octoprint-apt

but that would need sudo, so not sure best way to do the command in that case. so probably

sudo nano /etc/sudoers.d/octoprint-apt

and type in

pi ALL=NOPASSWD: /usr/bin/apt

ctrl+s to save and ctrl+x to exit.