Installing Home Assistant with HASSbian

Home Assistant is one of the most versatile and powerful home automation platforms and it is complacently open source. Once set up, it can be accessed from any web browser and allows your to create complex automation that put services like IFTTT to shame.

One of the things that I like most about Home Assistant is that it all works on my local network. No more remote APIs or giving your data to other people all while slowing down your internet. You control your data including what stays local and what can be accessed remotely.

This entire system can be run on a Raspberry Pi meaning that your personal smart home’s brain will run you about $35.

The following guid will walk you through the basic steps involved with setting up your own Home Assistant server with MQTT support.

What you will need

  1. One 4GB (or higher) SD card
  2. One Raspberry Pi (B+, PI 2, or PI 3)
  3. 5V 2A Power Supply with MicroUSB Cable
  4. Laptop or Desktop computer
  5. One network router with multiple Ethernet ports
  6. One Ethernet cable.

Lets get started

  1. Download the HASSbian disk image from: https://github.com/home-assistant/pi-gen/releases/latest
  2. Use any Disk Imaging software to install the HASSbian image onto the SD card that you will use with your Raspberry Pi. (Win32DiskImager or Etcher)
  3. Connect your Raspberry Pi to the internet via the Ethernet port.
    • Internet connectivity is needed when the Hassbian SD card is first installed into your Raspberry Pi.
  4. Insert the HASSbian SD card into the Raspberry Pi and connect it to power.
  5. When first starting up, the Raspberry Pi will connect to the internet and start to download Home Assistant. This can take as long as 30 minutes depending on your internet speed.
  6. While Home Assistant is downloading, open a new browser window on your computer.

Finding the IP address of your Raspberry Pi

Before we can do anything with your new Home Assistant install, we need to know what IP address your router has assigned to the Raspberry Pi. There are a few ways to do this, but the best way is to gain access to your routers administrative page.

Find your router’s IP address

Typically your home router should be at IP Address 192.168.1.1, otherwise known as your Gateway Address, but this address can be changed by an administrator. The easiest way to find your router’s IP address is to figure out what Gateway your computer is connecting to.

Windows:

  1. Click the search box from the Start Menu or in Cortana.
  2. Search for CMD to bring up a command prompt window.
  3. In the new window, type ipconfig.
  4. Press Enter to send the command.

This will display the information about your network connection. The IP address listed next to Default Gateway is the address for your router.

Mac:

  1. First, click the Apple icon in the top left corner.
  2.  Click System Preferences from the menu.
  3. Next, click Network.

The IP address next to Router is the one you want.

Connect to your Router.

From your web browser, type the IP address for your Router into the address box just like you would for a website.

Router IP

This should take you to the login page for your Router. Each Router will have it’s own menu system, but every one will have a way to see what devices are connected to it.

Your Raspberry Pi should show up as hassbian in the list of devices. Take note of the IP address that is assigned to it because that is how we will connect from now on.

Router listing

While you are here, you may want to reserve the IP address for hassbian so that it is always the same. Your Router’s help guide should tell you how to reserve the IP.

Connecting to the Home Assistant UI

Hopefully everything has downloaded by now and you should be able to access the Home Assistant UI by typing in the IP address assigned to your Raspberry Pi followed with :8123 to connect.

HA UI

If The Home Assistant page fails to load, just wait for a bit longer as the HASSbian update may not be completed. Go and get a snack, then refresh your browser window until the page loads.

Once the page loads, that means that everything is set up for the basic install.

Home Assistant should start to detect all of the name brand IOT devices that you may have connected to your local network. However, we will need to do some other things to get DIY devices like the ESP8266, NodeMCU, or other devices that require MQTT.

Customizing your Server

We can SSH into our new HASSbian server by connecting to the IP address assigned to the Raspberry Pi at port 22.

The default login is pi and the password is raspberry.

First, let us change the password so that others can not connect to your server’s administrative account by running the following command.

You will be prompted to enter a new UNIX password. Remember that this password is case sensitive. This is the ROOT access password for your new server. It is very important that you remember this password and never give it out to anyone that you do not trust fully.

Now we want to update the Time Zone.

Run the following command.

This will open the Configuration screen.

  1. Use the arrow keys to scroll to Localisation Options, then press the Enter key.
  2. Scroll to Change Timezone and press Enter.
  3. Scroll to your geographic location and press Enter.
  4. scroll to your time zone and press Enter.
  5. Scroll to Finish and press Enter.

Setting up WiFi

At this point, you can set up WiFi access if you are using a Pi3 or have a USB WiFi device connected to your Raspbery Pi. It is not necessary, but can be helpful if you do not want to be connected with a hard line.

Go to the bottom of the file and add the following:

Then run

Disconnect the Ethernet cable and your Pi should now connect via WiFi. You will have to find the IP address again as it will have changed, but you can connect to it normally.

 Installing Support scripts

Support scripts will add functionality to your Home Assistant server.

Samba support

First, let’s install Samba to make it easy to share files from the Pi.

Once finished you should be able to see the Raspberry Pi as a sheared drive that you can access just like any other disk. This will make it easy to update your interface files later.

Note: if the Raspberry Pi dose not show up as a Network drive, try entering a \\ followed by the IP address of the Raspberry Pi in the navigation bar at the top of the file browser window.

Samba

Mossquitto MQTT

MQTT is a communications protocol that is typically used in IOT devices and is most common with DIY electronics using the ESP8266. It is fast, secure, and highly versatile for machine to machine communication.

Mossquitto is an MQTT server that will work along side your Home Assistant UI. Together, there is no end to what can be accomplished between your devices.

You will be asked to enter a User Name and Password for access to the MQTT server. This will be the User Name and Password that all connected MQTT devices will have to use if they connect to your server.

you can test your MQTT connection with the following code replacing the MQTT Username and MQTT Password with your MQTT username and password.

For the configuration.yaml file, use the following code to add MQTT to the Home Assistant UI.

Be sure to replace the broker, username, and password with the IP address of your Raspberry Pi, the MQTT username you used, and the MQTT password that you set up.

If you are having issues with MQTT, try the following steps:

If you are having authentication issues, run the following code to update the MQTT user accounts. Be sure to replace the User part at the end with the user name that you are using for MQTT.

and

This will ensure that your user account and password are set.

 

This will show the currant status of your MQTT service. If the section listed as Loaded ends with “disabled”, do the following steps.

This will re-add mosquitto to the list of programs to execute on restart. This has been known to be broken when an update occurs.

 

 

So many support Scripts

This is all you really need to get started with things. There are many more scripts that can be installed and a full list can be found here and even more here.

  • Bluetooth Tracker
  • Raspberry Pi GPIO
  • Raspberry Pi Camera
  • One wire Sensor
  • CEC support (for HDMI)
  • OpenZWave
  • Tellstick
  • IKEA Trådfri Gateway Samba Support

So what now?

Any device connected to your local network can now access the Home Assistant UI. You may see a few things appear in the UI like Hue lights, Nest, Chrome cast, Plex, and a few other name brand IOT products.

In the next tutorial, I will walk you through customizing the UI and adding devices not supported by the auto detection function of Home Assistant.

If you can’t wait until then, here are a few links to more tutorials, videos, and information that I used to create this guide.

https://home-assistant.io/getting-started/

https://home-assistant.io/getting-started/configuration/

https://home-assistant.io/components/

2 thoughts on “Installing Home Assistant with HASSbian”

  1. Thank you!!!

    I have been struggling to get MQTT broker to work on hassbian 1.23 for days! Your instructions were great!

    1. No problem. I had a few issues with it myself until I found one post on the forums about MQTT updating after the first install and disabeling the automatic startup when the Picture reboots. It is an easy fix, but hard to find an answers about so I had hoped this would come in handy.

Leave a Reply

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