This week I bought an echo dot device and I wanted to try out some of its home automation features. I used Home Assistant (Python, Open Source).

For my test setup I added a LED on RPI port 18 (I used a 68 ohm resistor).

Alexa test setup

Install Home Assistant on Raspberry Pi

I followed the documentation for Home Asssistant for installation on a Raspberry Pi.

For headless setup, SSH can be enabled by placing a file named ‘ssh’, without any extension, onto the boot partition of the SD card.

$ ssh pi@raspberrypi

The default password of the RPI is raspberry. It is best to change the default password:

$ passwd

Home Assistant configuration

The Home Assistant is configured via the yaml config-file configuration.yaml.

$ sudo su -s /bin/bash homeassistant
$ nano /home/homeassistant/.homeassistant/configuration.yaml

At the end of the configuration.yaml file I added the folowing lines to enable the GPIO pin 18 and expose it via emulated_hue:

...
######## Changes by Mark ########
switch:
  platform: rpi_gpio
  ports:
    18: light

emulated_hue:
  type: alexa
  expose_by_default: true

Start Home Assistant service on the RPI:

$ cd /srv/homeassistant
$ . ./homeassistant_venv/bin/activate
$ hass

GPIO Switch setup

I am using Home Assistant’s rpi_gpio switch platform to control the LED via the RPI’s GPIO pin.

For this to work I had to add the homeassistant user to the gpio group:

$ sudo adduser homeassistant gpio

For detailed RPI pin info

Alexa discover devices

For the device discovery part I asked alexa to do the work:

!! alexa, discover devices

Visit Alexa Setup to setup a “desk” group which contains the light device:

Alexa setup device details

Alexa setup desk device group

Using Alexa

Now I can use Alexa to switch the light on and off…

!! alexa, turn desk light on
!! alexa, turn desk light off

I wish you a happy new year! Mark

Resources