Turn on (Wake on Lan) your Gaming PC via Google/Alexa Assistant with a Python Server and IFTT

Luca Cesarano
4 min readSep 29, 2020

--

My Rig

This is my rig.

Yes I’m flexing a little but focus on this:

Focus on the phone, not the lights!

There’s an old Xiaomi Mi4C working for it. It’s a very handful object that allows you to do many things. That phone is a nice assistant, and works really well for doing tasks like hosting a Home Assistant Server, like Checking the stats of your PC while you game/work or….

you could turn on your PC via a Python Script with your VOICE and Alexa/Google Assistant connected to IFTTT!

Well yes, why would you do that if you can just press a button? Because it’s easy to code and also cool to impress your friends or, more probably, just yourself… (why nobody likes cool stuff anymore?)

There’s actually a way to get the same result without writing any Python Script but the request is very very slow (because it’s all in the Cloud) and also less educational and also less exposed to the public (Privacy these days…)

Anyway, let’s get to it.

Requirements:

  • Python3 Environment (Computer, Raspberry PI, Android)
  • A WOL Enabled Motherboard (B550 user here!)
  • An Ethernet Connected Computer (you could say no but then it’s up to you to get crazy on getting working WOL on a WiFi Card, I tried and failed)
  • Know how to access your PC from the Internet (Port Forwarding and DynDNS)
  • A brain
  • Patience

Difficulty: very easy if you can issue some terminal commands and know a little how to work with code.

LET’S START

THE SERVER PART

You need a Python environment, in my case I used Termux for Android, but you can host the server on your Computer or whatever object has an installable Python Environment (a RaspBerry PI would be perfect).

Well, we’re on Android now so let’s install Termux.

So, download Termux and install Python3 on that issuing the following command:

pkg install python

Once you do it. Download my Python Server from my Github:

GITHUB

Modify the file .ini in the folder and replace the mac address on it. Search on the web how to find yours. Replace also the General address, it needs to point to the subnet where your device is located. In most cases it’s probably 192.168.1.255.

Run the main.py issuing ‘python3 main.py’ which starts a webserver on the port 7070 (you can change it in the code).

Try to reach the page on https://your-local-ip:7070/

You should see a blank page. No errors? Great! Errors? Probably a missing library. Try ‘pip install (libraryToInstall)’ to solve it.

BIOS CONFIGURATION

After you get everything up and running, be sure to enable Wake on Lan on your Motherboard in the BIOS.

There should be an option like

wake up via pci-e card”: enabledERP ready / energy star / CEC” : disabledfast boot” (at least on my MB): enabled

Every MB is different so here you’re on your own (or send me a message and I can try to help).

WINDOWS CONFIGURATION

Under Power Plan settings, buttons’ actions:

"fast startup": disabled (this is essential or it won't work)

Under Device Manager, go to your Network Card and under Power Management check the following:

allow this device to wake”: enabled
only allow a magic packet to wake up this device”: enabled

Under advanced:

enable PME”: enabled
wake from s0 on magic": enabled
wake on magic”: enabled
"wake on pattern" :enabled

Now let’s port forward this little devil and make it available from the outer space (not really, just the Internet).

…WE NEED CLEARANCE

You need to port forward the port 7070 on the ip address that runs the server and create a Dynamic DNS using services like NO-IP.

I’ve written a guide here for another Medium https://medium.com/@luca.cesarano1/install-home-assistant-hass-on-android-no-root-fb65b2341126

If it’s not enough, look on the Internet because it’s easy and useful in MANY MANY MANY situations so learn how to do it, trust me.

After you’ve finshed you should be able to access the webserver with the address you’ve created http://IKnowHowToWOLMyPCFromTheInternet:7070/

IFTTT IS SO COOL

We need to use IFTTT.

Create an account and create an applet.

IF THIS: Google Assistant [Alexa] — Say a Simple Phrase.

THEN THAT: Webhooks — make a POST request

in URL put the address you’ve created earlier.

After that, you’re set.

OK GOOGLE, ACCENDI PC.

Your PC should now turn on with your sweet voice. See you for the next dumb project that will waste my time. :)

--

--