A few things to add, since Wake-on-LAN either just works the first time, or is a headache to figure out why it doesn't:
* The target device might have to be on Ethernet, not WiFi.
* You might have to enable this feature on the target device, such as in the motherboard firmware setup for onboard network interfaces, and/or in the host OS. (I had a machine that required doing both, for an onboard Ethernet device.) For Linux host OS, such as on Debian Stable, if the device doesn't default to wake-on-LAN enabled, you'll probably use `ethtool`, testing it with something like the following, and then have to put the last line as an init/systemd script, so that enabling persists across boots.
ip a
sudo ethtool MYDEVICE
sudo ethtool -s MYDEVICE wol g
* You need to get the magic packet onto the right LAN. Maybe this means plugged into the same network switch or routed LAN, but it can get more complicated, even with small home WiFi routers, various ways. (Including if you're on WiFi but the target is not, or you're on a different VLAN, or it's isolating LAN devices from each other in the WiFi device or router, or any of multiple kinds of 'firewall' filtering is between you.)
* There are many ways to send the magic packet. Lately, I `apt install etherwake` on a host that's on the same LAN, or even the equivalent on a router once.
* From there, if the sending device has multiple network interfaces or VLANs, you might have to tell the program which to send the packet on.
* I sometimes make pairs of one-line scripts named `start-`<hostname> (which does Wake-on-LAN, possibly by SSH into a jump box of some kind) and `stop-`<hostname> (which does something like SSH to invoke `shutdown`). Kludgey, but they pretty much always work.
Related: I have a setup with a PC connected to my TV, it would be nice if there was some way to wake up my PC from sleep using a remote control of some kind. The best way I can think of is using wake-on-lan on another device like a raspberry pi. I could configure it to send the signal when it sees me push a button on my remote.
This doesn't feel very optimal though. Having a whole other device constantly running just to wake up my main device feels like a waste.
I think if you have recent (not sure how recent?) HDMI ports, you can do this via a HDMI cable, which you might already use for displaying purposes? Never encountered it myself until I recently got a PS5 and noticed it and the TV shared both control and power state, so turning on the TV turned on the PS5 before I disabled HDMI CEC.
Alternatively, maybe there are adapters for HDMI that could add/emulate it/something similar?
> The PulseEight USB-CEC adapter works by passively extending all the pins of the HDMI connector on from the "PC side" connector to the "TV side" connector, save for the CEC pin, which is intercepted. The data going through that pin is instead exposed over a USB serial interface to let a PC control and monitor CEC traffic
Edit: Ah, but that adapter wouldn't work for powering on the PC I suppose, I don't think USB has something like WoL.
In firmware interfaces you can configure whether USB and PCI-E devices can wake up the computer. Enabling USB wakeup made it possible on my machine, that I can wake it up by pressing any key on the keyboard.
My solution is tied to Home Assistant, which is running for the whole house 24/7 anyway, then, a Z-Wave smart plug to turn the PC on/off, and, finally, an EnOcean kinetic battery-less switch to toggle it on and off. While we're at it, Home Assistant also powers on/off the TV, sets the input, sets volume, and dims the living room lights.
Grab an arduino Leonardo, micro, or any board that supports USB HID emulation. Throw on a simple IR receiver module and set it up to send a keypress when the power code comes through.
You might have to explicitly enable "allow this device to wake computer" in device manager.
As far as I'm aware, there's no special sauce here. Your motherboard should support leaving USB ports on and allowing wake from USB HID devices. I don't know of any consumer board from the modern era that doesn't support it.
Beyond that, you could just throw a relay across the power switch pins. Plenty of ways to skin this cat
If you're already using microcontrollers, why not emulate a USB keyboard with one, and have an IR sensor that triggers a key press when it gets a signal?
Rewire the power button so it's an easy to push switch and put it behind a target. Then your remote can be a nerf gun.
Edit - the other thing that came to mind was to look into HDMI cec and see if there's a setup where turning on your tv will turn on the PC automatically.
Edit 2 - if you go with an app, you could use something like tasker and then you can have different triggers like your phone tapping an nfc sticker (then you don't have to unlock and find an app).
I find it unusual you have a device with a keyboard where the keyboard won't wake the computer. You must have some setting disabled for that to happen.
For Windows, maybe this helps.
1. Open Device Manager
2. Find the keyboard under "Keyboards"
3. Right-click and select "Properties"
4. Go to the "Power Management" tab
5. Make sure "Allow this device to wake the computer" is checked
I do this with a USB device that looks like a keyboard, but speaks CEC out the other end. TV turns on with the appropriate source selected, the keyboard sends a wake key.
I have this set up with a Flirc device. It listens for IR remote control keys and converts to ~keyboard keys. So the PC wakes up for the same reason a keyboard would wake it up. I can also control the PC that way, for watching movies and such. That's the main reason to do it actually, the waking up is just a bonus.
1. radio remote with usb dongle that emulates a keyboard, so usual wake-on-keypress wakes up the machine
2. systemd unit that when sleep ends sends "power on" to TV via IR blaster
Similar problem, since my personal home server may sometimes need a restart and may be unreachable, I need something like this that works over the Internet.
I use a cheap smart plug and PC auto start on power setting and it works beautifully.
You can make WoL work with a forwarded UDP port on your router. Most WoL tools also tolerate the use of a domain instead of an IP. Obviously this can't shut your server down.
Downside: unencrypted magic packets sent over the network could be captured and maliciously repeated for your annoyance.
* The target device might have to be on Ethernet, not WiFi.
* You might have to enable this feature on the target device, such as in the motherboard firmware setup for onboard network interfaces, and/or in the host OS. (I had a machine that required doing both, for an onboard Ethernet device.) For Linux host OS, such as on Debian Stable, if the device doesn't default to wake-on-LAN enabled, you'll probably use `ethtool`, testing it with something like the following, and then have to put the last line as an init/systemd script, so that enabling persists across boots.
* You need to get the magic packet onto the right LAN. Maybe this means plugged into the same network switch or routed LAN, but it can get more complicated, even with small home WiFi routers, various ways. (Including if you're on WiFi but the target is not, or you're on a different VLAN, or it's isolating LAN devices from each other in the WiFi device or router, or any of multiple kinds of 'firewall' filtering is between you.)* There are many ways to send the magic packet. Lately, I `apt install etherwake` on a host that's on the same LAN, or even the equivalent on a router once.
* From there, if the sending device has multiple network interfaces or VLANs, you might have to tell the program which to send the packet on.
* I sometimes make pairs of one-line scripts named `start-`<hostname> (which does Wake-on-LAN, possibly by SSH into a jump box of some kind) and `stop-`<hostname> (which does something like SSH to invoke `shutdown`). Kludgey, but they pretty much always work.