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;
- Raspberry Pi 3/3+/4 (Buy: Amazon, Aliexpress, Lazada)
- Casing for Raspberry Pi (Buy: Amazon, Aliexpress, Lazada)
- Power supply (Buy: Amazon, Aliexpress, Lazada)
- A2 class Micro SD card (at least 32GB) (Buy: Amazon, Lazada)
- Network cable
- USB Micro SD card reader (Buy: Amazon, Lazada)
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.