In this guide, I’m going to show you how to access and edit Home Assistant configuration files from Visual Studio Code (installed locally on your computer). To do this, we are installing the Samba Share addon, installing the Home Assistant Config Helper extension in VSCode, and then opening the Samba share from VSCode.
This guide is intended for Windows 10/Server 2019 users, although the steps should be pretty similar for Mac or Linux.
If you were looking for instructions on how to install the Visual Studio Code add-in from within Home Assistant (to use VSCode from your Home Assistant web interface), follow this guide instead.
For accessing Home Assistant via SSH, follow this guide.
Let’s get started!
Download Visual Studio Code from here.
Once downloaded, install with all default options.
Click the start button and search for VS Code to open Visual Studio Code Editor. On the left sidebar, click Extensions.
Then search for Home Assistant Config Helper and click Install.
Go to File > Preferences > Settings. Expand Extensions, and then open the Home Assistant Config Editor.
Under Host URL, enter the IP and port of your Home Assistant instance (mine would be http://192.168.68.124:8123) Check the box for ignore certificates.
Now, you’ll need to generate a long-lived access token. To do this, click your profile picture in Home Assistant:
Then, scroll to the bottom until you see the Long Lived Access Tokens section.
Click Create Token and name it VSCode.
Copy the generated token to your clipboard and then paste into the Long-Lived Access Token field in Visual Studio Code. Make sure to copy this, it will not be shown again.
Next, we need to download the addon called Samba Share from within Home Assistant. This enables file sharing across different operating systems on the same network, allowing us to access the HA configuration files via Windows File Explorer or vscode.
Supervisor > Add-On Store > Samba Share. Click Install.
Click Samba Share, and then click the Configuration tab. Set a password and then click Save.
Go back to the Info tab and start the addon.
As a quick test, open File Explorer in Windows. Type the path to your new samba share like this:
In the credentials box, use the credentials you configured in the Samba Share addon.
You should now be able to see the entire folder structure of Home Assistant!
To edit your config files, you have two options: editing them from Windows File Explorer or by opening the folder from VSCode.
Right click on configuration.yaml > Open With > Visual Studio Code.
Launch VSCode. Click the Explorer tab on the left sidebar, then click Open Folder.
Enter your Home Assistant IP address and credentials if prompted.
It will ask if you trust the authors of the files, click Yes.
You will now see your entire folder structure for Home Assistant!