How to install and configure Home Assistant

How to install and configure Home Assistant
Photo by BENCE BOROS / Unsplash

Home assistant helps you automate your home smart devices without the need for then to connect to the internet.

Every device today wants to call home. Take a washing machine for example: Why does it need to connect to the internet when it will always remain stationary in my home. It should be accessible over the local intranet. It can still send you notifications when your clothes are washed. I, myself, can't think of any scenario where I am out grocery shopping when I urgently need to be know what my washing machine is doing.

The security and data collection is another very serious concern for these type of devices. Most recently car manufacturer was found to be in a breach of more than 15 million customers. Or when washing machine using 3GB data a day, we all should be a little concern about how our machines speak to the internet.

Many people prefer to run HA on raspberry pi for it's lower power consumption but my suggestion is, don't try to achieve the perfect state and start where you are. Here I am going to show you how to install and run home assistant on your home server running ubuntu. I am going to use docker for this purpose as this makes the instructions platform independent. You can use any operating system; just install docker and docker-compose in it and you are good to go.

Install docker and docker-compose

This example is only for opensuse. Comment your os if you want to know how to install in any other OS.

open termnal and run below command (you may have to be sudo to do that):

zypper install docker docker-compose docker-compose-switch

sudo systemctl enable docker #Add docker to services for it to start as system startup

sudo usermod -G docker -a $USER #Add the current user to the docker group

newgrp docker #Create a new docker group

sudo systemctl restart docker #Restart docker

docker version #Check if docker is installed

docker run hello-world #Check if docker is running correctly

Go to the directory where you want to have home assistant resources.

# Go to home directory
cd ~
# create a directort called "homeAssistant"
mkdir homeAssistant
# Go to the directory
cd homeAssistant

Make a file called docker-compose.yaml using nano (If you have another editor installed, please use that.)

nano docker-compose.yml

Copy the below content into the editor:

---
services:
  homeassistant:
    image: lscr.io/linuxserver/homeassistant:latest
    container_name: homeassistant
    network_mode: host
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Etc/UTC
    volumes:
      - /path/to/homeassistant/data:/config
    ports:
      - 8123:8123 #optional
    devices:
      - /path/to/device:/path/to/device #optional
    restart: unless-stopped

Press ctrl+x and then Y to save the file.

Run below command for docker container to be set up:

docker-compose up -d

Go to localhost:8123 or host-ip:8123 and you should see the HA home page.

You can now create your smart home.

After finishing the above steps, You should see the following screen: