Home Assistant - first steps after installation

Home Assistant Oct 1, 2021

If you're here, then you've probably already read up about Home Assistant and have a decent idea of its capabilities - it's what made you want to get it in the first place. You're probably aware of the myriad ways you can install and host it:

  • on an Odroid N2+ (which is what I currently have)
  • on a Raspberry Pi
  • in a docker container (home assistant is, at the end of the day, a series of containers working together)
  • in a VM (I used to host an instance in Synology-based VM)

You'll also likely know that there are different types of installation, each of which have their own quirks, but most importantly, that there are some which do not have the 'Supervisor' tab built in. Please note that whatever you use, I will only be using Home Assistant which has 'Supervisor' and 'Developer Tools' built in, and for most of the options below, I'm only going to be giving you the 'Supervisor' method.

I will be showing you how to install an SSH terminal, HACS, VSCode, Samba, MariaDB, and creating automatic backups to your GDrive.


Before we get started, I want to run through a few of the screens we will use:

The Supervisor screen

First up, the Supervisor screen - found in the tray on the left hand side. This has 4 tabs, 'Dashboard', 'Add-on Store', 'Backups' and 'System'.

The Profile screen

The next is the Profile screen, accessible by clicking into your Profile name bottom left. While we're here, scroll down to the 'Advanced Mode' button and toggle it on. We'll need that later on.

Configuration screen

Finally, the 'Configuration' screen, from which we'll mostly access the 'Integrations' and 'Server Controls' options.

OK enough of that. Let's get started. I'm going to introduce you to what I think are 5 must-have services to install, as in the long-run they'll make your life easier.


SSH Terminal

This add-on let's you access the command line of your Home Assistant installation. Whether you've installed it via docker, in a VM or you have Home Assistant Blue/Amber/Odroid, this works for all.

  • Head over to the Supervisor screen, and click on the 'Add-on Store' tab
  • In the search bar at the top, type in 'SSH'
  • Provided you toggled 'Advanced mode' on in the Profiles screen we saw earlier, you should be given two options. We're interested only in the 'SSH & Web Terminal'
Click 'SSH & Web Terminal'
  • Click it, then on the next screen click 'Install'
  • Once it's installed, click on the 'Configuration' tab
The 'configuration' tab
  • To start with, add a username and password (removing the [ ] brackets)
  • If you want to, change the default network port (22 is a common SSH port which is normally the most vulnerable - if you change this, choose a random number above 20000)

I'm also going to walk you through how to create an authorized key - this makes your connection very secure, and means you don't need to enter your password each time from your computer:

  • Go to your command line on your computer (windows, mac or linux, it should all be the same)
  • Type in the following:
ssh-keygen

You should get a screen which looks like this:

  • Hit 'enter', or change the destination path you want to put the key into
If like me you already have a key generated for another service, like your NAS, then you will be asked if you want to overwrite this key. Don't do this. Instead, copy that already existing RSA key into the correct field in home assistant
  • You will be then asked to input a passphrase - you don't need to do this, so keep it empty if you like. If you do put it in, you'll then need to verify it
  • You'll then be shown a new fingerprint ID and the location of your new key
I've blurred out my contents here
  • Locate your new id_rsa.pub file in the specified directory, and open it with notepad or another text editor of your choice
  • Copy the whole string, and head back over to your home assistant browser, then copy it in in the same way as shown in the image below, including adding the - in front of it:
  • Hit save, then go back to the 'Info' tab
I normally toggle on all the options, it's up to you which you prefer
  • Hit start, then once after a few moments when it's started, go to the 'Log' tab at the top
You should see something like this
  • If you have no errors, you can now go back to your windows command prompt or other, and attempt to log in. This would be in the following format:
ssh [user]@[IP address] -p [port number]

So if your username was 'hass', your home assistant IP address was 192.168.0.5, and your port number was 88, you would type in

ssh [email protected] -p 88

If you've followed all the steps above correctly, you should be shown a screen similar to the following, without having to input your password:

ctrl+click to enlarge

HACS

the following requires you to have a Github account. If you don't already, please visit github.com and create a free account

We'll move swiftly onto installing HACS now, as we'll be using the SSH settings we just created. HACS is a fully third-party repository of cards and integrations for Home Assistant which aren't otherwise easily available, hence why I think it's a great add-on to have.

  • SSH in to your home assistant instance in the way shown above
  • Type the following and press enter:
wget -q -O - https://install.hacs.xyz | bash -
at time of writing this is correct, however double check the command at this github repository

The installation is normally quick.

  • Now you need to restart home assistant - head over to the 'Configuration' screen, scroll down to 'Server controls' and click RESTART
ctrl+click to enlarge
  • Once your instance has restarted, head over to the 'Configuration' and 'Integrations' screen
ctrl+click to enlarge
  • In the bottom right hand corner, click + ADD INTEGRATION and search for hacs in the pop-up screen. This will begin the installation and setup. Once done, you will be asked to confirm a number of check-boxes. Do so, and hit SUBMIT

You will now be shown a screen with a link to a github page, and an authorization key.

  • Copy the key, click the link, and paste the key into the 'Device Activation' screen. Hit 'Continue'
  • At the next screen, hit 'Authorize HACS', and you should see a completion screen like the one shown below:

Back in Home Assistant:

  • On the 'Integrations' page, you should now be able to locate HACS and hit the CONFIGURE button
ctrl+click to enlarge

Here you can change the name of the side panel title and various other options. I select all the checkboxes except 'Enable experimental features'. You can change this later if you prefer by accessing it in the same way.

Once you've hit submit, you should see the HACS icon is now available in the left hand tray:

you may need to restart your home assistant server again

Click it, and you will have access to all the options from HACS.


VSCode

Visual Studio Code is a Microsoft tool used far and wide. It supports many (all?!) the different coding languages available (and by that I mean it recognizes syntax and possible errors) and you can SSH directly from it. I use it daily on my Windows machine.

Pretty soon you'll want to start playing with the configuration files inside Home Assistant - while we've already looked at adding an integration, not all integrations are available via the GUI, and you'll need access to the configuration files. That's where VSCode comes in.

  • Head back to your 'Supervisor' screen from the button in the left-hand tray, and select the 'Add-on Store' tab
  • Either scroll or use the search bar to find VSCode
  • Click the INSTALL button and once it's finished, make sure you toggle the button to make it visible in the sidebar
ctrl+click to enlarge
  • Hit START then check the Log tab (top right) to make sure there are no errors
ctrl+click to enlarge
  • Click the 'Visual Studio Code' button in the sidebar to open it, and it should take you directly to a 'Getting Started' page, with the config folder open on the left hand side of the app
  • You can now explore all the files which you will inevitably need to access as you delve further into Home Assistant

Samba

You've installed VSCode but you've decided that it's too resource intensive for your system. Instead, you want to be able to access your HA config files from the comfort of your own Windows machine.

That's where Samba comes into play. This will set up a service which allows you to view, access and modify your HA config folders and files from your computer's File Explorer.

before we start, make sure you know the IP address of your Home Assistant instance. If you don't know it, it can be found in 'Supervisor' > 'System'. You can also change the IP address, along with your hostname if you wish
ctrl+click to enlarge
  • Again, hit 'Supervisor' then 'Add-on Store'
  • Search for 'Samba share', and hit INSTALL
  • Once it's installed, head over to the 'Configuration' tab at the top
most people will only need to add a username and password here, however if you know what you're doing, go ahead and modify the rest as necessary
  • Head back to the 'Info' tab and hit START
  • Once it's started up, in Windows, open a new File Explorer
  • In the address bar, type in \\your.home.assistant.ip and press enter
some of you may be able to type in \\homeassistant.local\config or similar, however the IP address will always work
  • Enter the username and password you set in the previous step, and you should now have access to your HA files from Windows

Maria DB

I'm not sure why, however HA doesn't ship with MariaDB as its default database type. Apparently, it's measurably faster, so most people I know recommend using it.

  • Make your way to 'Supervisor' > 'Add-on Store' and search for MariaDB
  • Click INSTALL and once done, head over to 'Configuration'
  • Add your username and password
due to the way we'll assign MariaDB as our database, avoid using the @ symbol in your password
  • Under rights add your username, but keep the database as 'homeassistant'
  • Hit SAVE then back to the 'Info' tab and hit START
  • Select your 'Visual Studio Code' app from the sidebar, and open your configuration.yaml file
  • Copy the following and paste it in, changing the username and password to match what you wrote above:
recorder:
  db_url: mysql://[username]:[password]@core-mariadb/homeassistant?charset=utf8mb4
ctrl+click to enlarge
note how the password is immediately followed by @core-mariadb. If your password has the @ symbol in it, this command won't work
  • Hit 'Configuration' and scroll down to 'Server Controls'
  • Check that your configuration is valid, then restart
  • Once your HA instance is back up and running, you can check that you're now using a new database by checking the 'History' tab in the sidebar. If you've been successful, your history should only be a few minutes old

Creating Automatic Backups

The 'Supervisor' tab allows you to manually create backups (previously called 'Snapshots'). These are stored locally in Home Assistant, and you have to do all the legwork to make sure you have access to these backups should you actuall need it (i.e. you break Home Assistant, which let's be honest, is easily done).

Luckily there's an existing integration which will automate your backups and store them on your designated google drive.

  • Head over to 'Supervisor' > 'Add-on Store', then hit the 3 dots top right and select 'Repositories'
ctrl+click to enlarge
  • Copy and paste the following into the field, and hit ADD
https://github.com/sabeechen/hassio-google-drive-backup
if it's added successfully, you'll be able to see it here
  • On the 'Add-on Store' main page, scroll down and select the newly available 'Home Assistant Google Drive Backup' integration, then click INSTALL
Make your toggle selections, then hit START
  • After the integration has started up, click OPEN WEB UI which will now be visible next to the UNINSTALL button
ctrl+click to enlarge
  • Click the blue button and follow the onscreen instructions to connect your google drive account. Once everything has been done, you should then see this screen, which will include any existing manual backups you may have already made:
ctrl+click to enlarge
one of the great things about this is that wherever you make a backup, it will be visible in both this screen, and the 'Backups' tab in the 'Supervisor' screen

Next, we'll need to configure the backup options we have to suit our preferences:

  • Click 'Settings' in the top bar
ctrl+click to enlarge
  • The first thing I would change is how many backups you want to keep locally and in Google Drive
bear in mind that you only have 15GB of free space in G-Drive, so pay attention to the size of your backups to make sure you're not going to save so many that it can no longer backup any further
  • Next, change the time between backups, the time of day so you know you have a fixed point of reference, and add a password. This is important as these backups live on the web
Change frequency, time, create a pasword, and change the naming template as desired
  • You can also look into generational backups, which will mean that you will keep x amount of days/week/months/years before deletion. This isn't necessary for all use cases, but can be helpful
  • Finally, you can change the look and feel - I for instance prefer dark modes, and so changed the background color using the color-picker
Change color if you like
  • Hit SAVE and your backup automation is created
  • Head over to your G-Drive and you should see a newly created backup

As mentioned, G-Drive has space limits. To help keep you informed, you can set up an automation based on a sensor which this integration will have created already:

  • Head over to 'Developer Tools' and in the 'filter entities' field type backup. You should be shown two sensors, we're interested in binary_sensor.backups_stale
ctrl+click to enlarge
  • Head over to 'Configuration' and 'Automations'
  • Click + ADD AUTOMATION in the bottom right corner of the screen, then in the pop up click START WITH AN EMPTY AUTOMATION
make these changes
  • Add a name and optional description
  • Change the Trigger type to 'State', the Entity to the 'binary_sensor.backups_stale', and the From and To fields to 'off' and 'on' respectively
  • Scroll down to 'Actions'
change these parameters to your preferences
  • Change the action/notification types to your preferences, add a message and optional title
  • You should now receive notifications when your backups can no longer be created
it's also possible to make a conditional lovelace card from this sensor which will pop up when it needs to. This could look something like:
type: conditional
conditions:
  - entity: binary_sensor.backups_stale
    state_not: "off"
card:
  type: markdown
  content: >-
    Backups are stale! Please visit the "Home Assistant Google Drive Backup" add-on
    status page for details.
  title: Stale Backups!`

How do I restore from a backup?

There are generally two reasons you'd want to do this:

  1. You still have access to Home Assistant but want to roll back to a previous configuration for whatever reason
  2. You either no longer have access to HA, or you have a newly installed instance

In the first case, you can access the backups web UI, select the backup you want to restore, and hit RESTORE at the bottom of the pop-up.

In the case of number 2 above, all your backups are now on G-Drive. Download the one you want, and in HA, before you create a user, click the Alternatively you can restore from a previous backup button on the setup page, and upload your backup.

And there you have it, the first steps towards a successful Home Assistant experience.

PTS

PTS fell down the selfhosted rabbit hole after buying his first NAS in October 2020, only intending to use it as a Plex server. Find him on the Synology discord channel https://discord.gg/vgSq5pcT

Have some feedback or something to add? Comments are welcome!

Please note comments should be respectful, and may be moderated