Wake up your PC using your Smartwatch!
I posted on Twitter yesterday stating that I had a working technology where I could wake my desktop PC up from anywhere in the world via my Pebble smartwatch. In this post I will show you how it is done.
A desktop computer running Windows Vista or higher (with Administrative priviledges)
A wake-on-lan server (This can be any Linux based device, I'm using a Raspberry Pi running Raspbian)
A web server (You could use the Pi for this, I've used a shared web hosting server I have)
(Optional) A Pebble smartwatch
(Optional) A dynamic dns address that points to your wake-on-lan server on your network (I'm using No-IP)
An Android and iPhone smartphone with mobile internet access
A free Yo! account (with the Yo! app installed on your iPhone or Android device)
Just a quick note before we begin. This system is very hacky and could be improved massively (when IFTTT decide to support Web Hooks). It may not work for you but it works for me.
In a nutshell, here is how the system works. Firstly, on our Pebble we are going to "Yo" the IFTTT official Yo! account (using the Yo! Pebble app linked to our internet-enabled smartphone). IFTTT will then fire our faked Wordpress trigger which will act as a middleman firing our custom endpoint. Our endpoint will then SSH into our Wake-on-lan server and run the relevant command in the local network to send the magic packet to our Desktop PC. We've setup our PC to boot when it receives that packet so the PC should boot up.
If that sounds like a whole lot of mess to you, my apologies. Feel free to keep reading or leave a comment on this post and I will answer it.
So, hopefully you have all the hardware you need to start setting up. The PC I am using is a Windows 8.1 custom-build Desktop PC, we just need to set the PC up to respond to wake-on-lan packets.
To do this, you will need Administrative access to your computer as we need to edit the ethernet network interface.
Note: Your PC must be hoked up to ethernet to support wake-on-lan
So we need to right-click on the network icon in your task tray and go into the "Network and Sharing Center".
In here, on the left sidebar, click on "Change Adapter Settings".
Then, right-click on your Ethernet adapter and select Properties.
In the new window, click on Configure.
This next window is the settings for your network card inside your PC. So we just need to click on "Advanced" and then click on "Wake on Magic Packet" in the list and enable it.
This means that when your PC is shutdown with the power plug left switched on, your network card will listen for a magic wake-on-lan packet.
That's it for the PC setup!
2: Setting up the wake-on-lan server
Next, we need a device that is switched on constantly that is on the same ethernet network as our PC. For this, I am using a Raspberry Pi but you could use anything that runs Linux and supports SSH.
My Raspberry PI also has a dynamic dns address associated with it so that it can be accessed remotely even if our network's IP address changes.
If you want to setup a dynamic DNS address to your Raspberry Pi, check out this guide.
So, once you can access your wake-on-lan server from the dynamic dns address, we just need to get a wake-on-lan server program running on the device which we can call to wake up your Desktop PC.
To do this, I have setup this awesome project (which is written in Python) in my home directory on the Raspberry Pi. This just requires your PC's MAC address and a friendly name for your PC. To do this, edit wol_config.ini.example to include your mac address and router broadcast and then rename the file to wol_config.ini and you're good to go!
Now what we can do on the wake-on-lan server is see if it can boot up your PC!
Firstly, shutdown your Desktop PC but leave the power plug switched on.
Then, SSH into your wake-on-lan server, cd into the directory with the wake-on-lan software in the directory and run this command:
This should then send the packet to your desktop PC, waking it up.
If it doesn't work so far, you may need to revisit your wol_config.ini file.
If it does, lets move on!
3: Setting up the web server
The next part for this is our publicly accessible web server. This part can be on your wake-on-lan server but it needs to be portforwarded so it can be accessed via your public IP address (or dynamic dns address).
For this, I am using a shared web host I have. Your server needs to have access to Composer for pulling down dependencies.
I have created a GitHub Repository with the files you need on your webserver. This is a fork of an excellent piece of code by captn3m0.
Just place these files in a folder on your server and run composer install to install any dependencies required.
Now just edit the config.php with your wake-on-lan server details and command to run through SSH.
This part is the main engine for this system. We need to setup IFTTT to call our web server when we Yo! the IFTTT account.
To set this up, first create a free account at IFTTT.com and then create a new recipe.
Now, select the Yo! trigger and "You Yo IFTTT".
Then for the action (what happens when you Yo IFTT), select Wordpress and "Create a post".
Then in the body of the post, you just need to add the URL of your receive.php on your web server.
and thats it! IFTTT will now listen for when you Yo! and call your web server accordingly, then your web server will call itself and call your wake-on-lan server.
5: Setting up your smartphone
Now all you need to do is download the free Yo! app onto your smartphone and Yo the IFTTT account! This should (after a few seconds) boot up your desktop PC.
6: (Optional) Setting up your smartwatch
As an added extension, if you have a Pebble watch connected via Bluetooth to your smartphone, you can download the free Yo! app to Yo from your smartwatch, thus starting the cycle.
Yes this system is a bit long winded and complex, it does work and really shows the power of how you can make a smartwatch boot up a full desktop PC.
Feel free to leave a comment below.