Home‎ > ‎Dabbles‎ > ‎RaspberryPi‎ > ‎

RaspberryPi 301 - Installing HomeAssistant

posted Nov 1, 2015, 1:41 PM by Joshua S   [ updated Nov 10, 2015, 1:38 PM ]
This tutorial will install HomeAssistant -- an open source home automation platform based on Python.  The tutorial will cover basic installation, configuring the service to start when the RaspberryPi starts, and initial connection to the interface.  This platform will be used to build out a while home automation system over the course of several courses.  To give credit where credit is due -- this tutorial is based heavily on the HomeAssistant tutorials for installation and auto-start for Systemd.

With any of the Dabbles on this site, if you have questions, suggestions, or thoughts, please feel free to send me an eMail (I'm still working to figure out how to enable comments on Google Sites -- suggestions would be appreciated)!


Supply List:
  • RaspberryPi  The actual RaspberryPi hardware this will all be built around.  In this tutorial, a Raspberry Pi 2 is used and has a memory card with the Raspbian operating system pre-installed.
  • PuTTY SSH Client – PuTTY is a free and open-source terminal emulator, serial console and network file transfer application. It supports several network protocols, including SCP, SSH, Telnet, rlogin, and raw socket connection.  Other SSH tools can be used, but this tutorial will leverage PuTTY.

Prerequisites:

Project:
  • I know I said this guide was going to be comprehensive and not skip any steps, so what better way to start this off than by skipping steps.  I am not writing out instructions for the following (and illustrating from XKCD):
    • Buying a MicroSD Card
    • Buying a RaspberryPi 
    • Finding the IP Address of your Pi
      • This can be done in many ways, including on your router or using an IP scanner such as (AngryIP Scanner or NMAP) -- if there are requests from the "Contact Me" form; I'll look to create a tutorial for this.
    • Obtaining and installing PuTTY
https://xkcd.com/1343/
  • Using PuTTY (or the SSH client of your choice) enter the IP Address or DNS Name of the RaspberryPi.
  • If this is the first time you connect, you will get a warning that the RaspberryPi's host key is unknown.  Click "Accept" or "Connect Once" to proceed with the connection.
  • Once connected, log onto the Pi using the pi username and builtin account.  It is important to use the pi account for purposes of this lesson as HomeAssistant will run under the pi account.  If you have not updated the password, you should, but these are the default credentials:
  • UserID:  pi 
  • Password:  raspberry
  • OK, good!  Now that we are connected, let's install let's install HomeAssistant.  Home Assistant requires the Raspberry Pi to run Raspbian Jessie. This version has been released on September 24, 2015 and comes by default with Python 3.4 which is required for Home Assistant.
pip3 install homeassistant

  • With the package installed, let's test to see if it works.  Execute the following command to launch the web based GUI, give it a couple of minutes to load and initialize, then connect to the Pi from your web browser at the following address.
sudo hass --open-ui
http://<IP Address Of Pi>:8123




  • Assuming this worked, back on the shell windows, use CNTL+C to cancel the GUI process and resume configuration.
CNTL+C

  • To automate the startup of HomeAssistant, we need to create a configuration file following the Systemd standards.  In this case we'll use nano and create the file like this.
sudo nano /lib/systemd/system/home-assistant.service

  • With the file created, we need to populate it with the following lines.  An example file is attached at the bottom of this lesson.
[Unit]
Description=Home Assistant
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/hass
User=pi

[Install]
WantedBy=multi-user.target

  • To enable the service, we need to restart Systemd and issue the start commands as follow:
sudo systemctl --system daemon-reload
sudo systemctl enable home-assistant
sudo systemctl start home-assistant

  • If all went well, we can now connect back to our web interface and we should see HomeAssistant running.  Connect using the below address and you should see a screen like one of the two below.
http://<IP Address Of Pi>:8123


  • Congratulations!  Your HomeAssistant platform is up and running!
ċ
home-assistant.service
(0k)
Joshua S,
Nov 1, 2015, 1:41 PM
Comments