Home Assistant Community Add-on: Visual Studio Code

How do I setup this VSCODE addon to connect and work with github in order to publish my configuration?

Hey guys,

Does anyone know if it is possible to disable this warning? Drives me nutsā€¦

insecure warning

1 Like

If I remember correctly go to settings: extensions: homeassistant: host url: and put in your url also put in a long live token in the workspace tab

1 Like

Is there a way to access this without the hassio interface? (w/ a port?)
Iā€™m trying to get a fullscreen coding experience for my iPad, and using it as an embed doesnā€™t support scrolling.

Not with a port but you can make it full screen. In the hassio interface it shows VSCode in an iframe. If you grab the URL of that iframe then you can go to that URL directly and just have VSCode full screen. Im not sure how to do that on an ipad but on desktop thereā€™s usually an option in the right click menu to open frame in a new tab. Then just bookmark that URL and send it to your ipad.

It is a really ugly URL, looks like <ha base URL>/api/hassio_ingress/<really long hash>. I donā€™t really know how it is constructed but I can say that you can safely bookmark it and reuse it indefinitely. Once in a while the ingress session seems to die and I have to open one of the ingress addons from the hassio interface to get it recreated, then I can go back to my direct links.

I rarely view any of the ingress addons in hassio interface anymore since I find it frustrating. I donā€™t mind the sidebar but the iframe messes with the interface of these apps in weird ways (like the scrolling thing). Also HA likes to refresh when I return focus on the tab after Iā€™ve been gone for a while and that is really frustrating with the ingress apps since you can lose your place and your work. That doesnā€™t happen anymore when you open them directly.

2 Likes

Iā€™ve found the hash changes on restart, and itā€™s difficult to get the embed code without inspect element. Any other ideas? I was thinking of just using syncthing and a local code editor on my ipad

Iā€™ve had the same hassio_ingress URLs bookmaked and the tabs pinned open for weeks. The Node-RED one Iā€™ve had pinned open for months. They still work without issue, the hash has not changed. Theyā€™ve survived host restarts, core and supervisor updates, I think at least one has even survived a restore from snapshot. Not sure why yours would be differentā€¦

Are you running HAOS or a supervised install? I run HAOS, could work differently on there I guess.

Anyway looking at its setup script it looks like the container is listening on port 1337 and does not bind to a particular host (set to 0.0.0.0). So if you run a reverse proxy I think you would be able to send traffic to it directly.

However word of caution. The addon specifically disables authentication since it expects all traffic to come from HA and thus have already been authenticated. So if you go this route definitely do not expose it outside of your network unless you plan to put an alternate authentication mechanism in front of it.

Iā€™ll retry the hassio ingress url. How did you obtain that? I tried it by just using inspect element, but I must be doing it wrong

*Also, the ingress URLs Donā€™t Work across devices. That must have been the problem I had, but now I donā€™t know how to obtain the URL in the first place

Huh, shoot, my bad. I didnā€™t realize this. I thought they did but I guess I hadnā€™t tried transferring the URLs between devices before, Iā€™m usually on my desktop when digging around in addons.

That would make this tough then. Only thing I can think of at that point is usually if you prefix a URL with view-source: in the browser it shows you the raw source. My phone doesnā€™t let me do inspect element but it does still let me do that, perhaps the ipad does too? Then could use find to look for hassio_ingress in there.

If that doesnā€™t work either then I guess use a tool like wireshark that can see the network traffic coming from your ipad and pick off the URL? At this point its becoming kind of a lot of work though so not sure how far you want to go lol.

I have a VPN tunnel already, so I ended up adding hassio as a file server to my ipad, and using a code editor that looks exactly like VScode. It works good enough for my liking :slight_smile:

1 Like

Hi everyone,
I admit that I am completely new to Home Assistant. I installed the supervised version on a RPi4 8 GB running the 32-bit version of Raspberry Pi OS.

When I wanted to install Visual Code Studio I get the error
This add-on is not compatible with the processor of your device or the operating system you have installed on your device.
Does anybody know what is causing this?

Thank you :slight_smile:

@AleXSR7001 I think you might need a 64-bit versionā€¦ this is from the documentation:

Known issues and limitations

  • Can this add-on run on a Raspberry Pi? Yes, but only if you run a 64 bits operating system. Also, see point below.
  • This add-on currently only supports AMD64 and aarch64/ARM64 machines. Although we support ARM devices, please be aware, that this add-on is quite heavy to run, and requires quite a bit of RAM. We do not recommended to run it on devices with less than 4Gb of memory.
1 Like

I have the same issue, I also get the 404: Not Found when trying to authorize. If I enter Github and check my Authorized OAuth Apps the entry ā€œcode-serverā€ is there, but I guess something did not register correctly.

1 Like

@Ronaldt & @runevad ,

I was able to get GitHub to authenticate and push via VScode on my pi. Here is how I did it.

  1. I attempted a push, which popped up the request to authenticate with GitHub.
  2. I went through the process and when it failed with a 404, I went back to VSCode and clicked the ā€œAuthenticate with GitHubā€ button at the bottom.
  3. When it asked for the Token, I hit escape
  4. Then it prompted for username, which I gave my email.
  5. Finally it prompted for password, which I used a personal token I had already generated. That seemed to work.

I have issues getting this addon to work when I access my Home Assistant instance remotely through HTTPS, and would appreciate some help. If I access my Home Assistant instance locally using local HTTP IP adress then it works as it should.

Iā€™m sure Iā€™m missing something simple in the config or my network setup, but I canā€™t figure it out on my own :frowning:

My setup is as follows:
I have a server on which I have a VM running HassOS. That VM uses a network bridge from the servers second NIC. On the same server I have a docker container for Letsencrypt/Nginx. Not sure if that is relevant, port 80 and 443 are forwarded to the servers first NIC. Accessing HA remotely using https://subdomain.mydomain works great so that appears to be correctly set up.

The issue:
When I try to access the VS Code Web UI from my external address I only get a white page. I tried waiting for several minutes to see if it starts. Restarted both HA and the VM, but nothing helps.

My VS Code config:

packages: []
init_commands:
  - ls -la /config
log_level: debug
config_path: /config

The log output:

[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: 3.3.1
 You are running the latest version of this add-on.
 System: Home Assistant OS 5.13  (amd64 / qemux86-64)
 Home Assistant Core: 2021.4.6
 Home Assistant Supervisor: 2021.04.3
-----------------------------------------------------------
 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... 
Log level is set to DEBUG
[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... 
[21:39:46] DEBUG: Requested API resource: http://supervisor/services/mqtt
[21:39:46] DEBUG: Request method: GET
[21:39:46] DEBUG: Request data: {}
[21:39:46] DEBUG: API HTTP Response code: 200
[21:39:46] DEBUG: API Response: {"result": "ok", "data": {"host": "core-mosquitto", "port": 1883, "ssl": false, "protocol": "3.1.1", "username": "addons", "password": "", "addon": "core_mosquitto"}}
[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... 
total 173100
drwxr-xr-x 10 root root      4096 May  6 21:39 .
drwxr-xr-x  1 root root      4096 May  6 21:39 ..
drwxr-xr-x  2 root root      4096 Apr 22 20:40 automations
[... all my files ...]
drwxr-xr-x  3 root root      4096 May  6 21:33 .storage
drwxr-xr-x  2 root root      4096 Apr 13 22:08 tts
drwxr-xr-x  6 root root      4096 May  6 12:56 www
[cont-init.d] user.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[21:39:46] INFO: Starting the code server...
[2021-05-06T19:39:46.889Z] info  Wrote default config file to ~/.config/code-server/config.yaml
[2021-05-06T19:39:47.164Z] info  code-server 3.9.3 fe2dc2deb08e378069891b622bb62ad1d261d1b1
[2021-05-06T19:39:47.164Z] info  Using user-data-dir /data/vscode
[2021-05-06T19:39:47.174Z] info  Using config file ~/.config/code-server/config.yaml
[2021-05-06T19:39:47.174Z] info  HTTP server listening on http://0.0.0.0:1337 
[2021-05-06T19:39:47.174Z] info    - Authentication is disabled 
[2021-05-06T19:39:47.174Z] info    - Not serving HTTPS 

The log says it not serving HTTPS, so perhaps that is the issue? Is it something I need to setup a Nginx config file for? Or modify my Nginx HA config file someway? Iā€™m not sure what I should add there because even if I try to use local IP:1337 I canā€™t access VS Code. I can only access it by going via local HTTP HA instance.

2 Likes

How can I turn on settings sync?

I only get this:
grafik

On the user icon I only get this. It never finished loading.
grafik

I am new on vs codeā€¦

And also most of the time I dont get any suggestions for entities. Sometime it works.

Hi

Just starting out with HASS and saw that a lot of people are using this.

I have a 3950x and am running HASS via a Virtualbox VM, when trying to start the addon I get this message:
404 Client Error for http+docker://localhost/v1.40/containers/create?name=addon_a0d7b954_vscode: Not Found ("No such image: ghcr.io/hassio-addons/vscode/amd64:3.4.1")

Can you help?

1 Like

Sorry also to confirm, the setup I did for this was following the one by this guy in case you need details on replicating it: https://www.youtube.com/user/GTOTechnology

somehow the add-on chokes on this anchor:

sensor:

  - platform: template
    sensors:

      presence_icon:
        friendly_name: Presence icon
        value_template: &icon
          >
            {% set presence = states('sensor.family_home') %}
            {% set mapper = {'0':'mdi:account-off',
                             '1':'mdi:account',
                             '2':'mdi:account-multiple',
                             '3':'mdi:account-multiple-check'} %}
            {{mapper[presence] if presence in mapper else 'mdi:account-group'}}
        icon_template: *icon
        availability_template: >
          {{states('sensor.family_home') is not none}}

and indicates all code above as ā€˜redā€™. removing the line of the icon_template checks all fine.


the code is working fine, and has been since for ever, its just that on my new HA 64 bits install, I finally could install the add-onā€¦

also, it errors on

 - alias: Dst change clocks
    id: Dst change clocks
    trigger:
      - platform: time
        at: '10:00'
      - platform: time
        at: '19:00'

with

while this is correct, according to the HA docs Automation Trigger - Home Assistant

Can be specified as HH:MM or HH:MM:SS . If the seconds are not specified, :00 will be used.

being new to the VSC, is this a bug ion the add-on?