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

Disclosure: This post contains affiliate links. If you click through and make a purchase, I will earn a commission, at no additional cost to you. Read my full disclosure here.

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.

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.

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.

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.

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.

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.

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.

About Liam Alexander Colman

is an experienced Home Assistant user who has been utilizing the platform for a variety of projects over an extended period. His journey began with a Raspberry Pi, which quickly grew to three Raspberry Pis and eventually a full-fledged server. Liam's current operating system of choice is Unraid, with Home Assistant comfortably running in a Docker container.
With a deep understanding of the intricacies of Home Assistant, Liam has an impressive setup, consisting of various Zigbee devices, and seamless integrations with existing products such as his Android TV box. For those interested in learning more about Liam's experience with Home Assistant, he shares his insights on how he first started using the platform and his subsequent journey.

Leave a comment

Share to...