Wake-On-LAN Server for Home Automation
This project builds a simple docker container that runs a webserver that allows you to send a wake-on-lan magic packet to the local network where the server is running by making an API call. Credit to https://github.com/sabhiram/go-wol for the magic packet code!
The intent of this service is that you have it running locally on a server in your home network as a docker container, and that it's exposed to the outside world. You can then use a webhook from a service like IFTTT or something similar to set up a voice command from a home automation assistant.
Running The Server
I run this in kubernetes, the manifests can be found in kubernetes/
and have a few values in < brackets >
that you need to configure.
No matter where you run it, the container or process needs to be running in the same network as the computer you want to send the Wake-On-LAN packet to. In kubernetes, that means the cluster has to be in the same network and you have to configure the pod with hostNetwork: true
.
A docker image is published to https://hub.docker.com/repository/docker/geezyx/wolserver that can be used.
You can also build the server by cloning this repository and running go build main.go -o wolserver
and then running ./wolserver
or wolserver.exe
if you are on windows.
Configuration
To run the server, you must provide two configuration values. If you use the manifests in the kubernetes/
folder you'll see the secret and configmap that inject these values to the deployment.
--api-key
flag or theWOL_API_KEY
env var: A value that must be passed as a query parameterapikey
to the server for authorization.--mac
flag orWOL_MAC_ADDRESS
env var: The MAC address of the network interface you want to send the magic packet to.
Triggering the Wake-On-LAN event
Make a call to /wol?apikey=
and the server will attempt to send a magic packet to the configured MAC address.
I use IFTTT to automate this with google assistant. I have a voice command configured with "Turn on my computer" that sends a webhook to the /wol
endpoint with the api key I configured.