Home Assistant

Open source home automation that puts local control and privacy first. Powered by a worldwide community of tinkerers and DIY enthusiasts. Perfect to run on a Raspberry Pi or a local server. 1


Note

For this guide you should be familiar with the basic concepts of

License

Home Assistant is written in Python and licensed under the Apache License 2.0. All relevant legal information can be found here:

Prerequisites

Your domain needs to be setup:

[isabell@stardust ~]$ uberspace web domain list
isabell.uber.space
[isabell@stardust ~]$

Installation

Create a virtual environment and install packages

Install Home Assistant in a virtual environment. Python 3.8 or later is recommended, so we’ll stick to 3.8.

[isabell@stardust ~]$ mkdir ~/homeassistant
[isabell@stardust ~]$ cd ~/homeassistant
[isabell@stardust homeassistant]$ python3.8 -m venv .
[isabell@stardust homeassistant]$ source ./bin/activate
[isabell@stardust homeassistant]$ python3.8 -m pip install wheel
[isabell@stardust homeassistant]$ python3.8 -m pip install homeassistant
[isabell@stardust homeassistant]$

First time startup

Now we can start Home Assistant for the first time in order to create all needed configuration files. Just run the following command in the created homeassistant directory with active venv.

[isabell@stardust homeassistant]$ hass
[isabell@stardust homeassistant]$

A directory containing config files is created at /home/isabell/.homeassistant. So you can terminate the homeassistant using Strg-C.

Configuration

Configure Home Assistant

Now it’s time to make a basic configuration. Home Assistant documentation to find out more about Home Assistant configuration.

Use an editor such as nano to edit Home Assistant’s configuration file:

[isabell@stardust ~]$ nano ~/.homeassistant/configuration.yaml

Modify external_url and internal_url.

homeassistant:
  name: Home
  latitude: 32.87336
  longitude: 117.22743
  elevation: 430
  unit_system: metric
  time_zone: Europe/Berlin
  external_url: "isabell.uber.space"
  internal_url: "0.0.0.0:8123"
  allowlist_external_dirs:
  allowlist_external_urls:
  media_dirs:
  legacy_templates: false

Setup a web backend

Note

Home Assistant is running on port 8123.

To make the application accessible from the outside, configure a web backend:

[isabell@stardust ~]$ uberspace web backend set / --http --port <port>
Set backend for / to port <port>; please make sure something is listening!
You can always check the status of your backend using "uberspace web backend list".
[isabell@stardust ~]$

Create a supervisord service entry

Create ~/etc/services.d/homeassistant.ini with the following content:

[program:homeassistant]
command=python -m homeassistant
autostart=yes
autorestart=yes
environment=PATH="%(ENV_HOME)s/homeassistant/bin"

After creating the configuration, tell supervisord to refresh its configuration and start the service:

[isabell@stardust ~]$ supervisorctl reread
SERVICE: available
[isabell@stardust ~]$ supervisorctl update
SERVICE: added process group
[isabell@stardust ~]$ supervisorctl status
SERVICE                            RUNNING   pid 26020, uptime 0:03:14
[isabell@stardust ~]$

If it’s not in state RUNNING, check your configuration.

Finishing installation

Now Home Assistant should be running and you can point your webbrowser to the configured domain in order to make the initial homeserver setup.

Best practices

Security

Change all default passwords. Look at folder permissions. Don’t get hacked!

And last but not least, don’t forget to check out the security checklist:

Updates

Note

Check out the packageindex regularly to stay informed about the newest version.


Tested with homeassistant 2020.12.2, Uberspace 7.8.1.0

Written by: Dirk <https://github.com/universalappfactory/>
1

https://www.home-assistant.io/, 30.12.2020