HomeHome AutomationAlexa, wake up my computer (Tasker too!)

Alexa, wake up my computer (Tasker too!)

Clearly, Cortana is the submissive one in this relationship!

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;

Buy Amazon Echo Dot 3rd Gen

Buy it using these links to support NotEnoughTech.

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.

TASKR PROFILE -Wake up PC
Profile: Wake Up Pc 
	Event: AutoNotification [ Configuration:Event Behaviour
Filter: pc (regex) ]
Enter: Wake Pc 
	A1: [X] AutoNotification Tiles [ Configuration:Tile: 2
		Command: pc=:=true
		Double Tap Command: pc=:=false
		Label: Home PC
		Icon: /storage/ic_desktop_mac.png
		State: 999
		Hide Notifications: true Timeout (Seconds):60 ] 
	A2: HTTP Post [ Server:Port:https://your_domain.com:1880 Path:/pc Data / 
		File:wake=%ancomm Cookies: User Agent: Timeout:10 
		Content Type: Output File: Trust Any Certificate:On ] 

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.

PayPal

Nothing says "Thank you" better than keeping my coffee jar topped up!

Patreon

Support me on Patreon and get an early access to tutorial files and videos.

image/svg+xml

Bitcoin (BTC)

Use this QR to keep me caffeinated with BTC: 1FwFqqh71mUTENcRe9q4s9AWFgoc8BA9ZU

M5Paper

Programable, ESP32 based awesome dev platform with 4.7 e-ink display by M5Stack

More HATs

client-image
client-image

Argon One M.2

Enclose Raspberry Pi 4 inside this great case with custom I/O, cooling and GPIO and M.2 SSD support

More cases on

client-image
client-image

Best Raspberry Pi Projects

How to use Raspberry PI as WOL (wake on lan) server

0
While you could wake up your PC from a mobile directly, having a dedicated server capable of doing so is the best solution. The reason is simple. You can hook up as many devices as you wish with a single endpoint. This is why Raspberry Pi is perfect for this.

Slow Internet Warning

0
From time to time my Internet grinds to a stop. Since Raspberry Pi 4 comes with a 1Gbps Ethernet, I decided to take advantage of it and create a reporting system in NodeRED that will monitor and report when the ISP is not keeping the contractual agreements. Works with Alexa, Google Home, Android and Windows 10.

How fast Raspberry Pi NAS is?

0
Let's see how fast Raspberry Pi NAS really is?

Argon18: Argon ONE SSD modification

0
Argon One case just got better - now you can boot it from USB without ruining the design thanks to Argon 18: Argon One SSD modification

HOW TO...

It took me 2 months to boot CM4 from NVMe

0
Complete beginners guide to Compute Module 4 boot from NVMe.

Raspberry Pi Zero 2 W vs other Zero boards

0
It's time to test the Raspberry Pi Zero 2 W against other Raspberry Pi boards from Zero series: power, WiFi, temperature and core performance

C/C++ and MicroPython SDK for Raspberry Pi Pico on Windows

0
A guide to SDK toolchain for Raspberry Pi Pico and C/C++ , Micropython on Windows.

A comprehensive guide to Grafana & InfluxDB

0
How to use Grafana and InfluxDB on Raspberry Pi for IoT sensors in home automation

How to boot Raspberry Pi 4 from USB

0
How to set up and boot Raspberry Pi 4 from USB drive - headless guide.