I came accross Home Assistant a few days ago and it looks like a nice Home Automation system, so… Lets try!
At this point i’m running several apps like Hue, IFTTT, Stringefy to make my home smarter and respond on actions or triggers. As i now came accross Home Assistant this looked promising because it already has a lot of extensions / sensors and so on. As i still had some old Raspberry Pi 1 (B model) I decided to use this one for this project. I was not sure if this would work because the Pi 1 is not that fast, but well let’s try and see what happens!
- Raspberry Pi (B-model or faster will do)
- 4GB memory card with Raspbian
- Network connection / wifi
First of all prepare your SD card with Raspbian and install it on the SD card and boot the Raspberry Pi. Next do some basic configuration like static IP (comes in handy 🙂 )and expand the filesystem (if needed).
Next we want to update to the latest version so we are sure we are using all the latest packages.
$ sudo apt-get update && apt-get upgrade
This can take a while depending on your Raspberry, please wait till everything is up-to-date and, if needed, reboot the system. When you system is up and running enable SSH so you can remotely connect to the system. This can be done by running raspiconfig and enable SSH from there. Now you should be able to connect with Putty (Windows) or vSSH (Mac OSX) to the system and configure it from you desktop / notebook machine.
Now we need to install Python3 as Home Assistant is written in Python.
$ sudo apt-get install python3 python3-venv python3-pip
We now installed Python3, virtual Environment and PIP (for installing python packages). After this is done we need to add a user so Home Assistant will run under its own user account.
sudo useradd -rm homeassistant
We now created a new user named “homeassistant”, also there is a home directory created in /home/homeassistant. Next we need to create some directorys from were Home Assistant will be running this can be done with the following commands:
$ cd /srv
$ sudo mkdir homeassistant
$ sudo chown homeassistant:homeassistant homeassistant
We switched to /srv and created a folder homeadssistant so we have /srv/homeassitant. The next and last command gave the user / group homeassistant owner permissions so it can write / run / read files from the location. This because we are running Home Assistant under the homeassistant user 🙂
Finally we can now start the installation of Home Assistant itself. This will be done with the following commands:
$ sudo su -s /bin/bash homeassistant
$ cd /srv/homeassistant
$ python3 -m venv .
$ source bin/activate
First of all we switch from the user Pi (default Raspbian user) to the Home Assistant user and start “bash” (command line interface”. Next we ChangeDirectory into /srv/homeassistant. Remember we installed Python3? Good, we now create a virtual environment with python (python3 -m venv .) DONT FORGET THE DOT (.) AT THE END! As last step we activate the environment and go into the environment so we can start installing Home Assistant!
If you followed all the steps you should see something like:
(homeassistant) homeassistant@raspberrypi:/srv/homeassistant $
If this is the case then you are in the virtual environment, now we can use PIP (yes we installed pip as one of the first steps 🙂 )to install Home Assistant and it dependencies. If you see the line above, type the following to install Home Assistant:
pip3 install homeassistant
Your whole line should then look like:
(homeassistant) homeassistant@raspberrypi:/srv/homeassistant $ pip3 install homeassistant
If you hit return it will start installing Home Assistant!