Configure Home Assistant editing its files

3 minute read

While many Home Assistant configurations and integrations can be made and configured without the need to edit files of any kind, others require at least a few lines of code to function properly.

Therefore, it is good to have and know some tool that allows you to modify the files. One of the simplest and most powerful is the File Editor Add-on for Supervisor.

Installation

Go to the menu SupervisorAdd-on Store and look for File Editor.

Add-on Store

It does not require configuration if we do not want to make an advanced use, for the moment, simply click on Install.

Once finished, we need to make sure that the start on boot and show in sidebar options are active.

File Editor settings

Restart the Home Assistant server from ConfigurationServer ControlsServer managementRestart

Restart HASS

Using File Editor

The File Editor button will appear on the sidebar, selecting it will open a new page with an editor, a snippet selector, and the configuration, search and file explorer buttons.

File Editor

If we click on the file explorer, we can open a configuration file and edit it from the editor. By default, the file explorer opens in the /config/ folder where the Home Assistant configuration is located.

Find the file configuration.yaml and click, it will open in the editor.

File Editor open configuration.yaml

Before starting, it should be noted that changing certain configuration files causes automatic methods in the Home Assistant such as the Lovelace interface or certain parameters in the configuration tab to be disabled. More advanced users prefer to use configuration files, as they gain more control and simplicity for backing up, as well as being a very convenient way to share configurations with the community.

In our first approximation, we are going to add a weather entity that refers to OpenWeatherMap. By default, Home Assistant brings a weather entity that makes use of the NRK (Norwegian Institute of Meteorology), which doesn’t work very well for locations outside Norway.

The first thing you should do is go to the OpenWeatherMap website and ask for a API key that we will use in the configuration of our entity. Register and access the free plan that the API key will give us.

OpenWeather API key

With the editor open, in the file configuration.yaml, paste the following code; changing YOUR_OPENWEATHERMAP_API_KEY by the API key you just got.

weather:
  - platform: openweathermap
    name: home
    api_key: YOUR_OPENWEATHERMAP_API_KEY

The order of each entity created in this file is to your liking, you will be accommodating it and creating groupings as you go including more lines. What is important is the spacing, since yaml is a language that takes into account the indent of the code.

Once you have edited the file, click on Save.

Save configuration.yaml

To reload the configuration, it is necessary to restart Home Assistant, a simple way, without having to go to the Configuration tab of the sidebar, is to click on the File Editor settings and click on Restart HASS.

This menu offers a multitude of interesting options such as listing icons, listing compatible components with Home Assistant, Shell command console…

Restart HASS

Wait a few minutes, as Lovelace is in automatic mode, when you enter the Overview tab, you should see the OpenWeatherMap card with your home location information (can be changed from the Home Assistant configuration menu).

Home Assistant Overview tab

To delete the entity met.no, since we are no longer interested, and as it has been registered by a visual integration, go to the Configuration menu ➡ Home Assistant Integrations, select the integration and click on delete. Restart again, and only the OpenWeatherMap card should appear.

This and other articles complement the documentation of the GitHub repository where all the configuration of my house is available.

Leave a comment