Home Assistant on a Raspberry Pi, that’s all you need to make your home smart. This free and easy-to-use software supports numerous home automation devices. You control the whole thing in the browser on your computer or in the mobile app.

Koen Vervloesem

In the previous article you read about the heart of a home automation system: the gateway. You can purchase them, but you can also easily build them yourself. Here we show you how to do that with a Raspberry Pi and the open source software Home Assistant (home-assistant.io).

rpi4

The Raspberry Pi 4 is a powerful home automation gateway

HARDWARE
First of all, you need a Raspberry Pi. Home Assistant supports the Raspberry Pi 3 Model B and B+ and 4 Model B. We have been running a fairly complex home automation installation for more than a year on a Raspberry Pi 4 Model B with 4GB RAM and it works without any problems. But for a basic installation, a Raspberry Pi 3 Model B or B+ will suffice, both of which have 1GB of RAM, though.

In this article, we’ll keep it simple and assume that Home Assistant can control all your other devices via WiFi or an external gateway such as the Philips Hue Bridge. Then you don’t need any additional hardware in the Raspberry Pi. It is also possible to add Zigbee or Z-Wave support directly to Home Assistant by connecting an extra transceiver to a USB port or the gpio header of your Raspberry Pi. Be sure to check out Home Assistant’s extensive documentation if you’re interested in it.

MICRO SD CARD
Home Assistant provides an installation file (home-assistant.io/hassio/installation/) for download. Make sure you download the correct disk file that matches the model of your Raspberry Pi. The 64-bit disk file is only needed with the Raspberry Pi 4 with 8GB RAM.

balena etcher
With a program such as balenaEtcher you write the installation file of Home Assistant to the micro-SD card

It is best to install Home Assistant on a micro-SD card with at least 32GB capacity, because the program writes a lot of data in its log files by default. And if the ticket is full, your gateway will be in trouble. Writing the downloaded disk file to the micro-SD card is done with a program such as balenaEtcher (balena.io/etcher). Choose the file (a gz file, but balenaEtcher will extract it itself) and then your storage device and then click Flash!.

preparing home assistant 2
The installation of Home Assistant can take twenty minutes.

INSTALL HOME ASSISTANT
We assume that your Raspberry Pi is connected to your network via an Ethernet cable. If you want to connect the Raspberry Pi via WiFi, follow the explanation in step 3 of the installation instructions on the Home Assistant website. After all, you still have to adjust the WiFi network data on the micro-SD card. Remove the micro SD card from your computer and insert it into the micro SD card slot of your Raspberry Pi. Make sure the network cable is connected and plug the power cable into the wall socket. Your Raspberry Pi will now boot.
And now it’s time to be patient. After all, the first time Home Assistant starts up, it downloads and installs the latest version, which can take up to twenty minutes. If your computer supports mDNS (Apple calls this Bonjour), you can now access Home Assistant’s web interface at http://homeassistant.local:8123 If not, check your router’s web interface to find out which IP address your Raspberry Pi is from. the dhcp server got. For example, if that is 192.168.0.102, visit http://192.168.0.102:8123 in your web browser. If everything goes well, you will now see that Home Assistant is preparing the installation.

printer found 2
Home Assistant finds the network printer itself and asks to add it

FIRST CONFIGURATION
After the installation is over, you will be asked to create a user account. Please note: this is not an online account, but only on your Raspberry Pi, because Home Assistant does everything completely locally by default. Also choose and confirm a password and click create an account.
Then Home Assistant asks you to mark the location of your house on a map. This information is used, among other things, to request a modified weather forecast. click on Next one. Home Assistant then searches for devices it finds in your network. For example, if your network printer is switched on, there is a good chance that Home Assistant will now find it. Click on a device to add it and then assign it to a room (Home Assistant calls it a area) to. You can also create a new room here, because Home Assistant only creates a kitchen, bedroom and living room by default. With a click on More you can also add additional devices yourself, but we’ll leave that for later. click on Complete to save the initial configuration.

overview 2
The Home Assistant overview already contains a few components shortly after installation

OVERVIEW
You will then see the Home Assistant web interface. It is divided into several tabs on the left. By default you will see the Overview tab. At the top there are round badges with information, such as the position of the sun, the power status of your Pi and whether there is an update for Home Assistant. Below that, you’ll find larger interface elements. By default, Home Assistant shows a block with the weather forecast based on your location and for each device that you have added in the initial configuration, there is also a block with information and possibly switches.

discovered 2
Home Assistant discovered Kodi on a Mac

DEVICES DISCOVERED
Chances are that after a while you will join at the bottom left Notifications see a number. When you click on it, you will see the message that Home Assistant has found a new device on your network. This is the case, for example, if you have started a program such as Kodi on one of your computers. In the notification, click Check it out. This will take you to the integrations page. You see the devices already found during the initial configuration, such as the weather service and the power status of your Raspberry Pi, but now also the newly discovered device in a blue frame. click on Configure to set up this device (what you have to fill in exactly depends on the type of device) and add it to Home Assistant or click Ignore if you are not interested in it.

new integration 2
Home Assistant supports a long list of devices,
software and services

ADD NEW DEVICES
But you don’t have to wait for Home Assistant to find a device. You can also add one yourself on this integrations page. At any time you can go to this page with a click on Institutions bottom left and then Integrations to choose. Then click on the orange button at the bottom right Add integration. You now get to choose from a long list of integrations. These don’t all have to be physical devices, by the way. Often it is also software that runs on your network or internet services that provide you with information.
You can add Plex Media Server in this way, but also a service that shows figures about corona infections, you can connect your Samsung Smart TV, Spotify and so on. If you already have a Philips Hue Bridge, IKEA TRÃ…DFRI connection hub or Xiaomi Gateway, you can also connect it with Home Assistant here. If you run into a problem, find the relevant integration in the list of integrations on the Home Assistant website (home-assistant.io/integrations). On the integration page you will find more information about how to connect it with Home Assistant. But in many cases, Home Assistant already recognizes your device and adds itself.

color wheel 2
You control an LED strip in Home Assistant via a Color Wheel

BADGES AND SWITCHES
If you open the overview tab after adding some devices, you will see a lot of badges: one for each sensor. And one device can contain multiple sensors: for example, a wireless temperature sensor gets separate badges for the temperature, humidity, battery status and so on.
Switches and lamps, on the other hand, each have their own frame. If you click on it, you often get extra options. For example, with a WiFi LED strip you will see a color wheel with which you can set the color of the RGB LEDs.

MOBILE APP
Home Assistant also has an official mobile app for Android and iOS. When you open it for the first time, it will automatically detect your installation of Home Assistant. If not, enter the IP address and port number, so for example
http://192.168.0.102:8123
Then enter the username and password that you created during the initial configuration of Home Assistant.

companion app 2
The official Home Assistant app gives you access to your home automation system on your Android phone or iPhone

Then the app asks if it can enable location determination. If you do that, Home Assistant can track your location and you can therefore automate things based on that. In the mobile app you see almost the same interface as in your browser. Furthermore, Home Assistant can now also see whether you are at home (or at least whether your phone is at home) and it adjusts your status (the badge with your name).

REMOTE ACCESS
By default, accessing Home Assistant via the web interface or the app only works if you are on the same network as your Raspberry Pi with Home Assistant. If you also want remote access to Home Assistant, you have to start with port forwarding, dynamic dns and a certificate. That can be pretty difficult. The makers of Home Assistant, who work for the company Nabu Casa (nabucasa.com), have provided a simpler solution for this: Home Assistant Cloud. For an amount of 5 dollars per month you can safely access your Home Assistant installation at home. You can try it for free for a month.

home assistant cloud 2
The makers of Home Assistant offer a service that allows you to
secure access to your home automation system from anywhere

FROM COMMUNICATION TO AUTOMATION
You can see that Home Assistant is able to communicate with all kinds of devices. If you have linked all possible smart devices in the house with Home Assistant, you will have noticed that the dashboard has become a mess. Fortunately, Home Assistant also offers extensive options for customizing that dashboard. We will look at that in the next article, in which we also explain how to automate things at home.