VS Code remote

Hi all
I have been making extensive use of the new-ish VS code feature remote development. TLDR it allows you to develop on a remote pi over SSH using VS code. This is useful both for editing config, but also if you are doing development which requires a physical pi, such as working with GPIO/I2C etc. A couple of gotchas, you need to install VS code Insiders addition, then install the Remote addon. You will then Remote: Connect to host and enter pi@ip and select the directory you wish to work in (.homeassistant).
Cheers

7 Likes

Sorry for this beginner question, does this also work with an hass.io running on the raspberrypi?

It doesnā€™t work on Hassio, which is a custom OS. Iā€™m running Hassbian

it also works great on HA in Docker on Ubuntuā€¦ thanks for the tip!!!

1 Like

@lubeda, on Hassio you can use the AddOn: Visual Studio Code.

The VSCode addon isnā€™t available for RPiā€™sā€¦ (or it wasnā€™t last time I checked)

1 Like

Oops! Sorry, didnā€™t know that.

1 Like

With Pi/Hassio you can still use VSCode and setup SFTP to automatically upload/download changes to files on your Pi.
So you both have a backup on your laptop/dev machine and can easily make changes to the files on the Pi.

Thanks for this tip, Iā€™m trialing that now, using docker-compose and starting home assistant with
CMD [ "python3", "-m", "homeassistant", "--config", "/config" ] in the docker-compose file.

I can connect to the folder ok but how do you restart home-assistant to show the latest changes? Any way to do automatic reloading?

Well now i am trying to develop on my windows pc with docker. There is still a lot to learn but the way looks right.

1 Like

I am also using the VSCODE remote dev a lot. But I have issues to use it on HomeAssistent. I am getting the follwowing error message, when I try to connect:

The remote host may not meet VS Code Server's prerequisites for glibc and libstdc++

any ideas how to fix this?

2 Likes

I tried everything possible for the past few days and realized that on HassOS, neither the SSH add-on nor direct SSH to the host will work via remote SSH on a local VS Code install on your desktop/laptop.

The add-on fails as Alpine Linux, which it is based on, does not support the required libraries that @Geraldf mentioned, in order to run remote SSH.

The HassOS host fails because it starts without a TTY and offers one only after the user types in ā€˜loginā€™.

Accessing the folder via a Samba mount works, but is much slower than SSH during git operations and often gives phantom file changes in git, probably due to permissions changes owing to Sambaā€™s default mask settings.

I wish there was a way to get SSH remote development to work. Leaving this comment here, in case anyone posts an approach that I might have missed.

3 Likes

@ajayjohn thanks for dissecting the issue, suggest raising it in the dev discord forums to ensure it isnā€™t missed (core devs not on this forum much)

Just did that. Thanks! :+1:t3:

It is avaible on 64bit OS Version on the Pi 3 and 4.

1 Like

I found another SSH plugin for VSCode that made the trick. Try if it works @ajayjohn

2 Likes

Still using this addon?
I try to connect to HA but get error message ā€œError while connecting to SSH FS homeassistant: Handshake failed: no matching client->server HMACā€

Everything works when I ssh to HA with terminal with the same credentials

1 Like

@hoogen Can you hare some info on how to get this setup?

1 Like

There is an add-on that provides VSCode Remote in Hassioā€™s edge repository . Iā€™ve been using it for the past week and it works well.

Sorry no, havnā€™t used this exept some testing about a year ago.