Home Assistant Tutorials How to Hassio

After installing Home Assistant, we need to get a little comfortable. Using a simple example, see how everything works here.

Home Assistant is managed by configuration files, so let’s start with a text editor. Any text editor can be used. I use

Home Assistant with Visual Studio Code

Important Note: If for some reason you installed Home Assistant not in a virtual environment, but in docker, you have been limited the ability to use a convenient text editor and all the features that this editor provides. To edit configuration files you need to install add-on Configurator. You can edit the configuration files in the browser. I came across notes that someone even likes it. In this case, you need to skip this section and proceed immediately to editing files.

We start the editor.

We need to define a workspace. The easiest way to do this is on the “Greeting” Under “Launch“Select”Add folder to workspace …”And select or create a folder in a convenient place:

Home Assistant - Configuration & Initial Setup 10

To assign a name to the workspace, perform “File”->“Save workspace as …

We are going to edit files over the network. To do this, we need to install the extension.

Go to the extension installation tab. Install SSH FS:

Home Assistant - Configuration & Initial Setup 11

We need a command bar:


In the panel, select “SSH FS: Create a SSH FS configuration”:

Home Assistant - Configuration & Initial Setup 12

In the opened tab “SSH-FS Settings“Set in the field”Name“Configuration name, in the field”Location“Select”Workspace settings.json”:

Home Assistant - Configuration & Initial Setup 13


Next, fill in the settings fields. I entered the following values:

“Merge” – No

“Lable” – Home Assistant

“PuTTY” –

“Host” – (You must enter your meaning)

“Port” – 22

“Root” – /home/homeassistant/.homeassistant

“Agent” –

“Username” – homeassistant

“Password” – (If you put , then when you connect, you will be asked for a password. If you enter a password, the connection will occur without asking for a password.)

“Private key” –

“Passphrase” –

Home Assistant - Configuration & Initial Setup 14


In the sidebar of VS Code on “SSH FILE SYSTEMS”->“Home assistant“Right-click and select“Connect as Workspace folder

Home Assistant - Configuration & Initial Setup 15

We get access to the folder with the Home Assistant configuration files.

Home Assistant - Configuration & Initial Setup 16

When starting, the Home Assistant reads only one configuration file – configuration.yaml. The remaining configuration files are read only if in configuration.yaml they are connected by teams ! include. Now all configuration files except configuration.yaml, are empty.

Open configuration.yaml.

At the first start, the Home Assistant determines the latitude, longitude, unit of measure and time zone by geolocation of the IP address. Change the values ​​in the fields “name”,“latitude”,“longitude”,“elevation” If you need a different value “time_zone”, Then you need to set it in a specific format.

Save changes.

Now you need to check for errors in the configuration. This can be done through the command line, but it is more visual through the web interface of Home Assistant itself. Go to “Settings”->“Check your configuration file and manage the server”:

Home Assistant - Configuration & Initial Setup 17

And click “Check configuration

Home Assistant - Configuration & Initial Setup 18

If there are no errors, we see the message:

“Configuration completed correctly!”

To make changes to the file configuration.yaml take effect you must restart the Home Assistant. But if changes were made to automations.yaml, customize.yaml, groups.yaml, or scripts.yaml restarting the Home Assistant is not required. It is enough to reload these files.

File configuration.yaml This is a regular text file designed to be easily understandable to humans. We will have to store sensitive data in it – passwords, API tokens, even longitude and latitude values ​​are considered confidential information. The Home Assistant has a mechanism that allows you to put this information into a separate file – secrets.yaml. This is very useful for a number of reasons:

  • – Passwords and API tokens are not scattered in different places in different folders and files, but are in one place – it’s convenient to manage them.
  • – You can share your configuration without having to delete or change your passwords.
  • – It is possible to use public services such as github to store a backup of your configuration.

Open file secrets.yaml. Add two lines:

lat: 59.9615 (You set your coordinates)

long: 30.4614

Save secrets.yaml.

In file configuration.yaml change the values ​​“latitude”And“longitude”For the names of longitude and latitude in secrets.yaml:

latitude:! secret lat

longitude:! secret long

Save configuration.yaml.

Home Assistant - Configuration & Initial Setup 19

We check the configuration files for errors, restart the server and make sure that the changes we made take effect.

Setting themes.

Now let’s see how you can install your theme in the Home Assistant.

Go to “Profile”And we see that now only one topic is available to us – default. In the folder with configuration files (where it is located configuration.yaml) create a folder themes. We will add files with themes to it.

IN configuration.yaml add lines:

  themes: !include_dir_merge_named themes

A finished topic can be obtained from the Home Assistant community in the topics section. For example, I chose the topic “solarized” In the themes folder, create a file solarized.yaml and copy the contents from the community page into it:

  primary-color: "#2aa198"
  disabled-text-color: "#859900"
  divider-color: "#586e75" #"rgba(255, 255, 255, 0.12)"
  paper-card-background-color: "#002b36"
  paper-grey-200: "#586e75"
  paper-item-icon-color: "#b58900"
  paper-listbox-background-color: "#002b36"
  paper-listbox-color: "#b58900"
  primary-background-color: "#073642"
  primary-text-color: "#839496"
  secondary-background-color: "#073642"
  secondary-text-color: "#859900"
  text-primary-color: "#839496"
  label-badge-background-color: "var(--secondary-background-color)"
  label-badge-text-color: "var(--text-primary-color)"
  paper-card-header-color: "#cb4b16"
  paper-grey-50: "#b58900"
  paper-item-icon-active-color: "#dc322f"
  paper-item-icon_-_color: "#FF00FF"   # no clue 
  paper-slider-active-color: "#dc322f"
  paper-slider-knob-color: "#dc322f"
  paper-slider-knob-start-color: "#b58900"
  paper-slider-pin-color: "#FF00FF"  # no clue
  paper-slider-secondary-color: "#dc322f"
  paper-toggle-button-checked-ink-color: "#dc322f"
  paper-toggle-button-checked-button-color: "#dc322f"
  paper-toggle-button-checked-bar-color: "#cb4b16"
  paper-toggle-button-unchecked-bar-color: "#b58900"
  table-row-background-color: "#002b36"
  table-row-alternative-background-color: "#073642"
  google-red: "#dc322f"
  google-green: "#859900"
  google-blue: "#268bd2"
  google-yellow: "#b58900"
  accent-color: "#cb4b16"
  paper-green: "#859900"
  paper-blue: "#268bd2"
  paper-orange: "#cb4b16"

We check the configuration and restart the Home Assistant.

Going to “Profile”Make sure that in addition to the topic default topic is available to us solarized.

Having reviewed the contents of the file solarized.yaml we see that in it the variables are assigned color values. There is nothing difficult to create your own, personal theme. A list of the main part of the variables can be found here.

Themes created by the community are compiled into the github repository.

Copy files from the repository to the folder we created themes. You can do this in any convenient way. I will do it directly from the VS Code terminal.

We open the terminal:

Ctrl + `

And connect to the Orange Pi:

ssh homeassistant@ (instead of we substitute our IP)

Enter the password.

Go to the folder .homeassistant:

cd .homeassistant

We need to clone the repository into a folder themes, but it cannot be done until the folder is empty. Now it’s easier for us to delete the file. solarized.yaml:

rm themes / solarized.yaml

Clone the repository into a folder themes:

git clone https://github.com/maartenpaauw/home-assistant-community-themes.git themes

If you want the cloned files to be displayed in the VS Code sidebar, you need to reconnect to the working folder – “Home assistant”->“Reconnect workspace folder

We check the configuration and restart the Home Assistant.

After rebooting to “Profile”->“Theme”15 new themes are available to us:

Home Assistant - Configuration & Initial Setup 20

Now set up automatic theme switching.

We’ll set everything up so that after sunset Home Assistant uses the theme “night“And after sunrise”solarized_light

To file automations.yaml we write:

- alias: 'Смена темы Home Assistant для дня и ночи'
    - platform: homeassistant
      event: start
    - platform: state
      entity_id: sun.sun
      to: above_horizon
    - platform: state
      entity_id: sun.sun
      to: below_horizon
    - service: frontend.set_theme
        name: >
          {% if states.sun.sun.state == "above_horizon" %}
          {% else %}
          {% endif %}

When creating automation, we use three events as triggers:

  • – launch Home Assistant
  • – the sun above the horizon
  • – the sun is over the horizon

When any of the triggers fires, we check the state of the object sun.sun.

If its value is “above_horizon”, Call the service frontend and set the theme solarized_light. Otherwise set night.

We check the configuration, reload the scripts. If there are no errors, after rebooting, the theme should change from default to “night”(If the sun has already set).

Even if there are no errors, the browser can still display the interface using the default theme (this can be seen on the video). In this case, you can either clear the browsing history in the browser, or open the Home Assistant in a new window, in incognito mode, or with another browser.

Let’s check the switch to “solarized_light

Go to the page “States“, in field “An object“Select”sun.sun” In field “State”We type:


Push “Get state” The theme changes for a while to “solarized_light” Then returns to “night

Now Home Assistant will automatically switch between themes every day at sunset and sunrise without the need to do anything on our part.

In conclusion, now try to set other topics yourself. You can also set the switch not exactly at the time of sunrise or sunset, but with a shift in any direction. You can also set the moment of switching not in the sun, but at a specific time in the morning and evening. This is useful if you want to automate the lighting of plants, or the aquarium, or the illumination of paths with lamps in the country.

Manage Electric Curtain Rods and Blinds on Radio Channel from a Smartphone.

Previous article

Install Armbian on Orange Pi Zero Plus2

Next article

You may also like


Leave a Reply