Setting up Home Assistant on the Raspberry Pi

In this tutorial for the Raspberry Pi, we will be showing you how to install and set up the popular automation tool called Home Assistant.

Raspberry Pi Home Assistant Thumbnail

Home Assistant is an open-source home automation software that was built with devices like the Raspberry Pi in mind.

The software is designed with a focus on protecting your privacy and keeping control in the user’s hand.

Using Home Assistant, you can track the state of all the devices in your home. You can even set up an automation to interact with them.

For example, you can set it so that Home Assistant will automatically turn on all your lights when it gets dark and while your at home. You can even set it up to dim the lights in your living room when you cast a movie to your Chromecast.

Thank’s to the great community, the Home Assistant software can successfully integrate with a wide range of devices, including Phillips Hue and Ring.

The Raspberry Pi is a great device to run your home automation. It is small, affordable, packs a ton of connectivity features, and uses a relatively small amount of power.

Equipment List

Here is a list of the equipment we recommend for setting up Home Assistant on the Raspberry Pi.

Recommended

Raspberry Pi 1, 2, 3 or 4

Micro SD Card

Power Supply

Ethernet Cord or WiFi dongle (The Pi 3 and 4 has WiFi inbuilt)

Optional

Raspberry Pi Case

We tested this tutorial on setting up Home Assistant on a Raspberry Pi 4 running the latest version of the Home Assistant software.

Downloading Home Assistant for the Raspberry Pi

1. Before we get started, we must download the version of HASS that we need for our device.

In our case, this decision is based on what version of the Raspberry Pi you are using. The Home Assistant team recommends that you use either the Raspberry Pi 4 or 3.

To download Home Assistant we need to go to the latest release page on the Home Assistant GitHub page.

2. On this page, you will see a list of available downloads.

Find the file for the version of the Raspberry Pi that you are using and click it to begin downloading the file. The filename should end in .img.gz.

Raspberry Pi Home Assistant GitHub Download Page

Installing Home Assistant to an SD Card

Once you have downloaded the Home Assistant OS image, we can proceed with writing it to an SD Card.

1. For this section, we will be making use of the image writing software called Etcher.

Etcher is a simple tool that is available on both Windows and macOS.

You can download Etcher from Balena’s website.

2. With Etcher open, you need to select the Home Assistant image you downloaded in the previous section.

Do this by clicking the “Select Image” button and using the file browser that pops up.

Select Home Assistant OS Image

3. In this next step, you need to select the SD card you want to write the image to.

To do this, you need to click the “Select Target” button.

Select SD Card to Write To

If you only have one drive that’s writeable to, Etcher will automatically select it as the target.

4. Once you are certain you have selected the correct drive to write to, click the “Flash!” button.

Flash Home Assistant to Pi SD Card

5. If you want to set up your Raspberry Pi to use WiFi, you will need to hold off inserting your SD card and follow the next section.

If you are using an Ethernet internet connection, you can skip down to our first boot section.

Setting Up Wi-Fi for Home Assistant

In this section, we will be showing you how to set up Home Assistant to connect to your Wi-Fi connection.

Make sure you still have your SD Card plugged into your computer before you complete these steps, as we will need to make some changes to it.

1. On the “hassos-boot” partition, start by creating a folder called “CONFIG“.

The Home Assistant software will automatically read this folder for any configuration changes.

Create CONFIG Folder

2. Within the “CONFIG” folder, we need to create another folder called “network“.

Create network Folder

3. Finally, in the “network folder, we need to create a file called “my-network“.

Create my-network configuration file

4. Inside the “my-network" file, we need to insert the configuration that will define our network for the Home Assistant software.

For this step, you will need to replace three pieces of information.

You will need to first replace “<UUID>” with a new UUID. You can generate a new generic UUID using an online UUID generator.

Secondly, you will need to replace “<WIFISSID>” with the SSID of your WiFi network.

Lastly, you will need to swap out “<WIFIPASSWORD>” with the password for the WiFi network you are trying to connect to.

[connection]
id=my-network
uuid=<UUID>
type=802-11-wireless

[802-11-wireless]
mode=infrastructure
ssid=<WIFISSID>
# Uncomment below if your SSID is not broadcasted
#hidden=true

[802-11-wireless-security]
auth-alg=open
key-mgmt=wpa-psk
psk=<WIFIPASSWORD>

[ipv4]
method=auto

[ipv6]
addr-gen-mode=stable-privacy
method=auto

5. You should now be ready to go and boot up your Raspberry Pi and start the Home Assistant software.

First Boot of Home Assistant on Your Raspberry Pi

1. Now we can open up the Home Assistant software.

To do this, we will need to go to one of the following web addresses in your favorite web browser.

For most users, you should be able to get to the Home Assistant homepage by using the following URL.

http://homeassistant.local:8123

Alternatively, if that doesn’t work, you can also try going to the following URL. Sometimes strict network configuration can block these hostnames from working correctly.

http://homeassistant:8123

The last option requires you to know your Raspberry Pi’s IP Address. As you can’t use the terminal at this stage, you will need to likely retrieve this from your router.

Replace “[IPADDRESS]” with the IP address of your Raspberry Pi.

http://[IPADDRESS]:8123

2. The initial boot of Home Assistant on your Raspberry Pi can take some time.

If you see a “Site Can’t Be Reached” error or a screen as we have below, then try and wait at least 20 minutes.

The reason this process takes so long is that the software is downloading the latest available version of Home Assistant as well as preparing everything for you.

Prepearing Home Assistant on Raspberry Pi

3. Once the initial boot of Home Assistant has finished, you may need to refresh your web browser.

The first thing you will be asked to do is to create a user for the Home Assistant software.

Enter the details for your user (1.) then click the “CREATE ACCOUNT” button (2.)

Create User Account

4. This next screen will ask you to give a name to your “home” (1.)

You will also need to set your location. Setting your location helps the software handle automation tasks that take into account the sun’s position.

To make this process easy, you can click the “DETECT” button (2.). This button will try to automatically work out where you live and configure the location and time zone for you.

Next, you need to select the unit system (3.) that you use. By default, this is set to “Metric“.

Once done, click the “NEXT” button (4.) to proceed.

Set Up Initial Home Data

5. You will now be shown a list of devices that the Home Assistant software has already detected.

You can either set them up now by clicking the + icon (1.) above the device name or finish up the initial setup by clicking the “FINISH” button (2.).

Add First Home Assistant Devices

6. You have now successfully finished the initial setup of the Home Assistant software on your Raspberry Pi.

You will now see the default Home Assistant dashboard, the more integrations you add, the more information you will see on your dashboard.

Raspberry Pi Home Assistant Dashboard

Adding Additional Integrations to Home Assistant

1. After the initial setup, it is possible to add additional integrations to your setup.

To add additional integrations, clickConfiguration” in the sidebar.

Configuration in Sidebar

2. Next, click the “Integrations” option.

Select Integration Menu Option

3. On this next screen, you will see all the devices that Home Assistant has automatically detected. (1.)

If you don’t see a particular device or integration, you can add them yourself by clicking the plus icon in the bottom right-hand corner of the screen. (2.)

This will bring up a search menu that allows you to look up the different integrations available through the Home Assistant software.

Add Additional Home Assistant Integrations

At this point, you should now have the Home Assistant software successfully running on your Raspberry Pi.

If you have run into any issues with getting the software to work, then feel free to drop a comment below.

2 Comments

  1. Gerard. on

    Hello How do you create a configuration file ! in the step setting up for Wifi!
    ++++
    4. Inside the “my-network” file, we need to insert the configuration that will define our network for the Home Assistant software.
    +++++
    is it a TXT file or ?

    1. Emmet on

      Hi Gerard,

      The file shouldn’t have a file extension on the end of it.

      All you need to do is create a file called “my-network”

      And open it within notepad or a similar program that deals with plain text, then enter the configuration using that.

      Cheers,
      Emmet

Leave a Reply

Your email address will not be published. Required fields are marked *