If you edit Home Assistant YAML in Visual Studio Code, you need this extension

No comments
Disclosure: This post contains affiliate links. If you click through and make a purchase, I’ll earn a commission, at no additional cost to you. Read my full disclosure here.
Advertisement
home-assistant-helper-vscode-extension-00.png

Visual Studio Code has been a soaring success for Microsoft. The free and source-code editor was ranked the most popular developer environment tool in the Stack Overflow 2019 Developer Survey, just four years after its initial release.

Advertisement

Visual Studio Code has also proven to be a popular tool for editing Home Assistant YAML code. While YAML is being phased out more and more, there are still many integrations that haven’t been ported to the UI yet. So while we still have to edit YAML, we might as well make it as easy and efficient as possible.

Table of Contents

Home Assistant Config Helper

If you, just like me, edit your Home Assistant YAML code in Visual Studio Code, you need the Home Assistant Config Helper extension installed. And the installation couldn’t be easier, it’s all done from within the app itself.

Advertisement

Installing the Home Assistant Config Helper

Press Ctrl+Shift+X on your keyboard or click on the extensions icon in the left-hand menu. Then simply search for Home Assistant and the first result should be the Home Assistant Config Helper. Select the extension and click on install. You will then be prompted to configure the extension.

Installing the Home Assistant Config Helper
Configuring the Home Assistant Config Helper

Configuring the Home Assistant Config Helper

With the settings open, search for the Home Assistant Config Helper under Extensions. Next, enter the URL of your Home Assistant host. This can be the internal or public address.

Advertisement
Setting up Home Assistant in the Home Assistant Config Helper settings

Open Home Assistant and click on your username in the main menu. Scroll all the way down until you see the box titled Long-Lived Access Tokens. Create a new token by clicking on create token. Give this token a name (e.g., Visual Studio Code) and click OK. You will next be presented with said token. Copy the token and paste it into the Visual Studio Code settings. You must never share this code with anyone. If that were to happen, make sure you immediately delete it in Home Assistant. For the settings to apply, you might have to restart Visual Studio Code.

Creating a long-lived access token in Home Assistant

Using the Home Assistant Config Helper

To use the Home Assistant Config Helper, you will have to change the language in Visual Studio Code to Home Assistant in the bottom bar.

Advertisement
Setting the Visual Studio Code language to Home Assistant

What the Home Assistant Config Helper does

The Home Assistant Config Helper does many things to help speed up your editing. I’ll highlight a few of my favourite features in the following paragraphs. A list of all the features can be found on the projects GitHub page.

Completion for entity IDs, services, scenes, and triggers

Let’s say you’re creating a new automation or setting up a binary sensor for room occupancy. Instead of painstakingly looking up the correct IDs of the entities you want to be included, the Home Assistant Config Helper will present a list of all available entities from which you can select the right one. The same goes for scenes, triggers, and services.

Using the Home Assistant Config Helper

Completion and validation for configuration and Lovelace schema

Properties, values, and enums will be auto-completed and most schemes that Home Assistant uses will be validated.

Advertisement

Go to definition for includes

I use a lot of includes in my configuration, and thus this feature is very dear to me. By highlighting an include and clicking F12, it is possible to easily navigate between files.

Using the Home Assistant Config Helper

Visual Studio Code Community Add-on

If you use the Visual Studio Code add-on, you’re in luck because there’s nothing left to install for you. This extension is already included.

Leave a comment

Share to...