How to Install Home Assistant on Raspberry Pi

Let’s get started with the first step into the world of Home Automation. Before that, a word of warning;

This may cause you to spend a lot of money, lose appetite, sleep and hair. You will have the tendency to talk only about your smart home when you meet with another human being. This also might cause you to lose contact with that human being.

If you are OK with all that, let’s jump into the rabbit hole.

There are many methods to install Home Assistant and the recommended one is to use Hass.io method. However, when I first started with Home Assistant, there is no Hass.io. Therefore, I would like to think that the method I used to install Home Assistant is the “original” method and that is the method I am going share in this guide.

Whatever method you choose, you need to get ready these items first;

Once you get them and do the necessary preparation on the Raspberry Pi, it’s time to get your hand dirty. For those who never work on Linux via command line before, you should execute each lines at a time and no need to write/copy the dollar sign “$”.

Install the dependencies:

$ sudo apt-get install python3 python3-venv python3-pip libffi-dev libssl-dev

Install Home Assistant

$ sudo useradd -rm homeassistant -G dialout,gpio,i2c
$ cd /srv
$ sudo mkdir homeassistant
$ sudo chown homeassistant:homeassistant homeassistant
$ sudo -u homeassistant -H -s
$ cd /srv/homeassistant
$ python3 -m venv .
$ source bin/activate

Once you have activated the virtual environment (notice the prompt change) you will need to run the following command to complete the installation.

$ python3 -m pip install wheel
$ pip3 install homeassistant
$ hass

Wait for the setup to complete. This may take awhile (5-10 minutes) initially. Subsequent restarts will be much faster. Once completed, you can load the front end at http://[IP ADDRESS]:8123/. You can stop it by pressing CTRL + C.

Update Home Assistant

In the future, when there is a new version of Home Assistant and you decided to update it, this is how you do it;

$ sudo -u homeassistant -H -s
$ source /srv/homeassistant/bin/activate
$ pip3 install --upgrade homeassistant

If you need to know more details on the steps you have taken, you may refer to the official guide.

Make Home Assistant start on boot

So far, your Home Assistant will only start when you execute hass command from the command line. However, it is better to have Home Assistant start automatically each time you reboot your Raspberry Pi and this is how you do it.

$ su pi
$ sudo nano -w /etc/systemd/system/home-assistant@homeassistant.service

Copy and paste this…

[Unit]
Description=Home Assistant
After=network-online.target

[Service]
Type=simple
User=%i
ExecStart=/srv/homeassistant/bin/hass -c "/home/homeassistant/.homeassistant"

[Install]
WantedBy=multi-user.target

Save and exit (CTRL + X)

$ sudo systemctl --system daemon-reload
$ sudo systemctl enable home-assistant@homeassistant
$ sudo systemctl start home-assistant@homeassistant

You can also substitute the start above with stop to stop Home Assistant, and restart to restart Home Assistant.

There you have it; your first taste of Home Assistant. It doesn’t do much at the moment, but stay tune to get your hand even dirtier with something call YAML.

If you wish to be alerted whenever I post a new article in this blog, you can follow me via RSS, Email or Facebook Page.

Spread the love

Author: Ben

He is the mastermind behind this blog. When he is not tinkering with smart home stuffs, he develops and hosts websites for other people.
{"cc_re__cc_re__cc_by_3_0": ["\"/><input type=\"hidden\" name=\"loc\" value=\"en_US\"/><input type=\"submit\" value=\"Subscribe\" /><p>Delivered by <a href=\"https://feedburner.google.com\" target=\"_blank\" rel=\"noopener noreferrer\">FeedBurner</a></p></form></div>\n\t\t</section><section id=\"text-423378256\" class=\"widget widget_text\"><h2 class=\"widget-title\">Credits</h2>\t\t\t<div class=\"textwidget\"><div>Icons from <a title=\"Flaticon\" href=\"https://www.flaticon.com/\" target=\"_blank\" rel=\"noopener noreferrer\">www.flaticon.com</a> is licensed by <a title=\"Creative Commons BY 3.0\" href=\"http://creativecommons.org/licenses/by/3.0/\" target=\"_blank\" rel=\"noopener noreferrer\">CC 3.0 BY</a></div>\n</div>\n\t\t</section>\t</aside><!-- .sidebar .widget-area -->\r\n\r\n\t\t</div><!-- .site-content -->\r\n\r\n\t\t<footer id=\"colophon\" class=\"site-footer\" role=\"contentinfo\">\r\n\t\t\t\t\t\t\t<nav class=\"main-navigation\" role=\"navigation\" aria-label=\"Footer Primary Menu\">\r\n\t\t\t\t\t<div class=\"menu-main-menu-v2-container\"><ul id=\"menu-main-menu-v2-1\" class=\"primary-menu\"><li class=\"menu-item menu-item-type-custom menu-item-object-custom menu-item-home menu-item-3938\"><a href=\"https://www.benleow.com/\">H"]}