Home Assistant Community Add-on: Visual Studio Code

HI All,

I get message:

Error connecting to your Home Assistant Server at https://localhost and token 'eyJ0e...', check your network or update your VS Code Settings, make sure to (also) check your workspace settings! Error: ERR_CANNOT_CONNECT

I tried all kind of things
I created a LONG LIVE TOKEN

https://hassio.myowndomain.com
http://hassio.myowndomain.com:8123
http://192.168.100.24:8123
https://192.168.100.24
http://localhost:8123
https://localhost
localhost
192.168.100.24
192.168.100.24:8123

Nothing is workingā€¦

This may be a long shot in but vscode did you goto settings, extensions, homeassistant and enter the required information Iā€™m not on my normal machine right now to show exactly where

I know where to enter the info. But it didnā€™t work

Few questions :

  • Are you using DuckDNS for accessing HA from outside? This is what I use and in this case you can access from outside with something like https://mysubdomain/duckdns.org. DuckDND also provides the https certificates

  • I suppose that you have correctly forwarded the external port 443 to 8123 so you log to ha from outside? If you try to oen vscode from HA the adress should be something like: https://mysubdomain.duckdns.org/a0d7b954_vscode

  • If you have installed Samba access your config directory and check that you have a .vscode directory that contains a file called settings.json. In this file you should find your long live token and you vscode url. The file should look like:

{
"vscode-home-assistant.longLivedAccessToken": "eyJ0eā€¦..j2HM",
"vscode-home-assistant.hostUrl": "https://mysubdomain.duckdns.org"
}
  • Does the error message you are showing coming from the log tab?

The normal log file should look like this:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-banner.sh: executing...
-----------------------------------------------------------
 Add-on: Visual Studio Code
 Fully featured VSCode experience, to edit your HA config in the browser, including auto-completion!
-----------------------------------------------------------
 Add-on version: 2.9.1
 You are running the latest version of this add-on.
 System: Home Assistant OS 5.9 (aarch64 / raspberrypi4-64)
 Home Assistant Core: 2020.12.2
 Home Assistant Supervisor: 2020.12.7
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing...
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] code-server.sh: executing...
[cont-init.d] code-server.sh: exited 0.
[cont-init.d] mosquitto.sh: executing...
[cont-init.d] mosquitto.sh: exited 0.
[cont-init.d] mysql.sh: executing...
[cont-init.d] mysql.sh: exited 0.
[cont-init.d] user.sh: executing...
[cont-init.d] user.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[16:00:01] INFO: Starting the code server...
[2021-01-04T15:00:05.198Z] info Wrote default config file to ~/.config/code-server/config.yaml
[2021-01-04T15:00:07.556Z] info code-server 3.7.4 11f53784c58f68e7f4c5b3b8dae9407caa41725b
[2021-01-04T15:00:07.582Z] info Using user-data-dir /data/vscode
[2021-01-04T15:00:07.701Z] info Using config file ~/.config/code-server/config.yaml
[2021-01-04T15:00:07.710Z] info HTTP server listening on http://0.0.0.0:1337
[2021-01-04T15:00:07.712Z] info - Authentication is disabled
[2021-01-04T15:00:07.715Z] info - Not serving HTTPS

Hi There,

I donā€™t use duckdns. I use my own domain and look like this:

https://hassio.mydomain.com (mydomain.com is placeholder)
443 is forward in router to 8123

As you can see in my post I tried this already without luck.

{
    "vscode-home-assistant.longLivedAccessToken": "eyJ0eXA..........AZH8",
    "vscode-home-assistant.hostUrl": "https://hassio.mydomain.com"
}
[cont-init.d] user.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[16:46:08] INFO: Starting the code server...
[2021-01-06T15:46:09.801Z] info  Wrote default config file to ~/.config/code-server/config.yaml
[2021-01-06T15:46:10.922Z] info  code-server 3.7.4 11f53784c58f68e7f4c5b3b8dae9407caa41725b
[2021-01-06T15:46:10.926Z] info  Using user-data-dir /data/vscode
[2021-01-06T15:46:10.957Z] info  Using config file ~/.config/code-server/config.yaml
[2021-01-06T15:46:10.958Z] info  HTTP server listening on http://0.0.0.0:1337 
[2021-01-06T15:46:10.958Z] info    - Authentication is disabled 
[2021-01-06T15:46:10.959Z] info    - Not serving HTTPS

I restart VSC and in right down corner saw: Activate extensions and then done. No errors at this momentā€¦

If I understand in the Info tab you click restart and then ā€¦
Did you looked at the log tab content?
Back to the Info tab what happen if you click ā€œopen web uiā€?

After I restarted VSC I donā€™t see the error that it canā€™t connect.
Now when I open a YAML file is ee ā€œactivating extensionā€ and thats it.

When I make a mistake on purpose then I get a message that something is wrong in the yaml file.

Seems to work nowā€¦

good to know :slight_smile:

hi all,

i use the first time VScode and i use all the time phpstorm with github.

How can i config the VScode in a available git repository ?

edit:
in the VScode config i found this line: git.defaultCloneDirectory

but my edit dont work:
"git.defaultCloneDirectory": "https://github.com/XXXXX/homeassistant.git",

normal i need this:
git remote add origin https://github.com/XXXXX/homeassistant.git
Error: fatal: remote origin already exists.

it works now:

git remote set-url origin https://github.com/XXXXX/homeassistant.git

git remote -v

origin  https://github.com/XXXXX/homeassistant.git (fetch)
origin  https://github.com/XXXXX/homeassistant.git (push)

Thanks all

hi all,

after save a file with this code {{namehere}} he do this auto. { { namehere } }

how can i change it? Thanks All!

Hi all,

I would like to ask, if there is any possibility to run and debug python3 code using this addon? After installing python support package in VSCode and pressing F5 on simple code, nothing happens. Additionally no python related command is working, like configure interpreter and so on.

In console I am able to open python interpreter, install pip packages and so on.

I love this Add-On! It doesnā€™t seem to have bracket matching though, so I tried to install the Brackets Colorizer extension for VSCode, but it doesnā€™t work either.

Am I missing something? Why does VSCode not have bracket matching natively & why does adding a VSCode extension not work?

1 Like

Hi all
Is there a way to install platform IO IDE?
I get error: missed ā€˜distitilsā€™ in Python installation
I use ova img

I would love to use this add-on in a 2GB RPi4 that I paired with an SSD. I understand the 4GB memory requirementā€“is there any swapfile functionality that would lower the memory requirements? or is there an experimental install workaround possible?

Iā€™m getting repeated warnings in the Supervisor log like this:

'ssl' does not exist in the schema for Visual Studio Code 
'certfile' does not exist in the schema for Visual Studio Code 
'keyfile' does not exist in the schema for Visual Studio Code 
'disable_telemetry' does not exist in the schema for Visual Studio Code 

I access HA through Ningx Reverse proxy and everything else works perfectly.

How would I fix this?

After latest update of VSC to 3.1.1 I canā€™t open the WebGui in Safari.
Clear cache, clear history didnā€™t work.
Get a black screen

It is working on Chromeā€¦ without problemsā€¦

When I do inspect in Safari I get those errors:

To install Platform IO in Visual Studio Code addon you need to add package in configuration:

packages:
  - python3-distutils
init_commands:
  - ls -la
log_level: info

I am not sure how it will works but at least it installed so need more tests

1 Like

I have the same issues as @poudenes,
Doesnā€™t work in Safari, but works in Chrome. Cleared caches, restarted browser etc.

Iā€™m trying to get GIT working in the VSC add-on. Before I was running a Raspberry Pi and used to do my config via Visual Studio Code over samba. This was quite slow when doing GIT, but it worked (-ish).

Now that I have upgraded to HA Blue (odroid) Iā€™ve installed the add-on and got it all configured except for GIT.

Now I canā€™t get GIT authenticated whatever I try. Not via HTTPS or SSH, not via tokens and also (which started it) not via the ā€œregularā€ login to GitHub option in the add-on.

When I try to do a git command (fetch, pull, push) I get a popup:

The extension ā€˜GitHubā€™ wants to sign in using GitHub.

When I then click on the [Allow] button a new tab opens with just a 404: Not Found. This is on the URL (masked):
https://my.home.assistant.com/callback?vscode-requestId=xxx-xxx-xxx-xxx-xxx&vscode-scheme=code-oss&vscode-authority=vscode.github-authentication&vscode-path=%2Fdid-authenticate&code=xxx&state=xxx-xxx-xxx-xxx-xxx
(also tried the local IP address on port 8123)

It also pops up a window with Password for https://github.com and when I fill in my personal password the popup closes, not doing/showing anything. No logs, nothing.

In the bottom blue status bar of VSC it shows Signing in to GitHub.com, but nothing happens.
When I click that message, I get another popup asking me for a token. When I paste in a token (newly generated with appropriate permissions) the same happens; pop-up closes but nothing happens.

Here a CLI log of what happened:

Error: socket hang up
    at connResetException (internal/errors.js:610:14)
    at Socket.socketOnEnd (_http_client.js:453:23)
    at Socket.emit (events.js:327:22)
    at endReadableNT (_stream_readable.js:1220:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  code: 'ECONNRESET'
}
remote: Repository not found.
fatal: Authentication failed for 'https://github.com/xxx/ha-xxx.git/'

I know for a fact the repo exists, been using it for a while. Even made it public (was private before) just to be sure.

I have 2FA enabled on my GitHub account. Could that be the cause, and if so how can I go around that? Also tried adding SSH keys but that does nothing either.

Add-on version: 3.3.0
You are running the latest version of this add-on.
System: Home Assistant OS 5.12 (aarch64 / odroid-n2)
Home Assistant Core: 2021.4.0b3
Home Assistant Supervisor: 2021.03.9

Whelp!

Is there a option to add automatic a last change line op top of every file you edit?