It’s not the first time I deal with this project, and oh boy, each time it does change quite a bit. How is this different this time? And why would you care? You are aware that I run a NodeRED of my $5 Raspberry Pi Zero to handle and distribute all request at home. Having a server doing this for you means a better flow of your commands. This is why Alexa, wake up my computer project integrates Amazon Echo, Tasker, and NodeRED. I will show you how to wake up and put the computer to sleep from the Echo Dot and your mobile.
Alexa, wake up my computer
Before I dive deeper into the tutorial, I will assume you know how to connect Alexa and NodeRED and Alexa and Tasker. In addition to this, I will use a simplified notification system. I have to assume that you have a network card that is capable of WOL. Otherwise reading this tutorial might be little pointless. Lastly, I will be using EventGhost and AutoRemote to communicate with the computer, NodeRED, and Tasker. Read more about the AutoRemote setup here.
Using the guide Alexa and NodeRED, create a new device and name it gracefully ‘Computer’ or else. I’m going to use that skill to send the signal ON and OFF to handle the sleep and wake actions.
NodeRED – Alexa, wake up my computer
NodeRED is responsible for listening commands coming from Alexa and Tasker and passing it over to the computer. It will also notify my mobile about the whole process. I have a single flow that is responsible for this.
PC node
The node is created as per Alexa and NodeRED tutorial. It will pass an mgs.payload which has a bool value.
True/False switch node
The node receives the true or false message and based on the value performs a wake-up function or sends a sleep message to the computer.
Wake PC wake on LAN node
The node has to be enabled in the palette settings. Add the MAC address of your computer’s network adapter and broadcast the wake-up packet to entire network by setting 255.255.255.255.
Sleep PC AR HTTP POST node
This node sends an AutoRemote message to the computer:
https://autoremotejoaomgcd.appspot.com/sendmessage?key=YOU_RAR_KEY&message=pcsleep
This message is intercepted by the computer and EventGhost puts the machine to sleep.
Pixel config change node and AR Message subflow
As discussed in the Tasker and NodeRED notification tutorial, this node will send the message to my mobile informing the mobile that my computer just went to sleep or has been awakened. The information will be confirmed again from the computer itself.
HTTP POST wake node
Previously I have sent the AutoRemote messages directly to my PC, this time around I’m using a HTTP request instead. Please note that my requests are sent to an SSL enabled NodeRED – so either follow my certification tutorial or strip the HTTPS from the links. I’m submitting a bool value as well wake=false/true. The node takes the request from /pc path. A mandatory response node has been attached to the request as well.
Get the object value function node
To format the msg.payload and receive the value of the key wake (mgs.wake) we have to run a small function that returns the value and sets it as mgs.payload – the same value that would be assigned by Alexa.
msg.payload = (msg.payload.wake == 'true') ? true : false; return msg;
Computer
By this stage, you are able to use Amazon Echo to wake the computer, but you won’t be able to put it to sleep or receive the confirmations until you use EventGhost. In a nutshell, EventGhost will put the computer to sleep after the message has been received (updating the mobile notification) and will also send a notification that computer is online.
The AutoRemote message should be formatted in a similar way to the one issued by NodeRED.
node=:=not=:=501=:=Computer=:=offline
Notification source =:= notification type =:= notification ID =:= Title =:= text. I want this notification to replace the Waking up/Going to sleep one, therefore, I’m using the same ID number.
Tasker
Once everything else is ready, we can take a look at Tasker setup that will display the notifications for Alexa, wake up my computer project and let us control the computer. There are only 2 profiles. One to handle all notifications (discussed in Tasker and NodeRED notifications) and the other one that will put the computer to sleep or wake it up.
You can totally ignore the AutoNotification tile if you wish – create your own ‘button’ to handle the ON/OFF commands. To send the request to NodeRed I’m using HTTP POST:
https://your_domain.com:1880 /pc wake=%ancomm
The Raspberry Pi handles the request and processes it. The commands issued by AutoNotification tiles are true/false to make the process easier. Make sure you use https for certified servers and http for not.
Conclusion
As you see – offloading the tasks to the Raspberry Pi comes with big advantages. Issuing commands to the server is much easier, you can create multiple clients working together and receive instant feedback. As usual, I have included all files needed to recreate this project. Be aware that you have to modify all the URLs in the files to get it to work.
Project Download
Download project files here. Bear in mind that Patreon supporters have early access to project files and videos.