Monday, April 03, 2017

Alexa, Turn on Computer

There is many ways to wake your computer up and put your computer to hibernate using Alexa.

I will use:

1. computer with cygwin enabled with sshd service
2. domoticz on a raspberry pi
3. ha-bridge on raspberry pi
4. Amazon echo

I'm more of a computer user than a developer, but I find that Domoticz is great as it helps non-developers download unix commands and allow a direct call to shell scripts.

More great things about Domoticz is that it convert HTTP POST to GET methods when you are using triggers that can't do POST to Philips Hue lights (I will cover that in another post)


Step 1: Setup a dummy hardware used for virtual switches



Step 2: Create a virtual sensor as a light switch called Computer

For the On script use:
script:///home/pi/domoticz/scripts/pc-wake.sh

The bash script should contain

#!/bin/bash
wakeonlan  BC:5F:F4:88:92:B6


For the Off script use:
script:///home/pi/domoticz/scripts/pc-hibernate.sh

This bash script contents are; (Replace X with the IP address of the computer)

#!/bin/bash
ssh user@192.168.1.X "shutdown /h" &


The off switch assumes you have an sshd service running on your computer with private keys installed on the raspberry pi with no password so it auto autenticates and runs without entering a password. Windows 10 command to hibernate is shutdown /h

You will need to google again to find out how to setup sshd, as it's too long to put into this post.


For ha-bridge to use this, add the domoticz command to Computer (Replace NN with switch ID, you can get this from the devices tab under the "Setup" drop down.

On
http://192.168.1.Y:8080/json.htm?type=command&param=switchlight&idx=NN&switchcmd=On

Off
http://192.168.1.Y:8080/json.htm?type=command&param=switchlight&idx=NN&switchcmd=Off


To use

Alexa, turn on computer
Alexa, turn off computer






No comments:

Splitting the home network

Who wouldn't want to separate the traffic at home for security reasons. The more common ones include wireless guest and wireless users. ...