Development pipeline with vscode

I have gone through a few setups for the VS code remote vs local, etc.
Is there a proven implementation to use VS Code on my PC to develop for my Home Assistant implementation? My current setup and what I would like to achieve:

  • Proxmox server running HomeAssistant
  • VS Code Server add-on. This is how I develop all my implementations today, from configuration to dashboard, etc.

What I would like to get to:

  • VS Code on my windows PC
  • Access to all the files on my HomeAssistant installation in VS Code local.
  • Use Github to maintain version control on all changes I make
  • Use copilot for help with coding.
  • Test on the HomeAssistant installation when I have changes made

Being the same development files on both HomeAssistant and local, should be used interchangeably. If I make changes in the VS Code server add-on, I should see those in my local version of VS Code.

I read from a tunnel plugin, ssh, or even samba.
Any advice on which way to go to get my intent going?

There’s nothing to stop you from doing that, but I would not trust the Co-Piliot thing unless it specifically trained on the current HA docs and rules. Otherwise you will be developing with 6month+ old code.

The homeassistant extension that works in the add-on also gives you local HA access to your files from remote.

Agree. I only use copilot for education. I will try to get the setup going and see how I can get the access locally vs. residing on my Proxmox HA VM.

Is there a specific reason you want to use the HA installation in your proxmox server?
I assume it is running HAOS which means you won’t be able to access the HA install itself which is inconvenient for development.

I think most people use the devcontainer or manual environment as described in the developer documentation Set up development environment | Home Assistant Developer Docs

This basically means you run a separate instance of Home Assistant on your development machine. That way the restarts of HA will not interrupt your regular HA instance. Also because you only need to load the integration you are working on it restarts really fast.

Personally I still use a manual environment in WSL (I never bothered to investigate devcontainer, but I hear lots of people liking it). So In my case VS code is on my Windows machine, VS Code connects to WSL and then I can use git in terminal window in VS Code or from the VS Code sidebar. CoPilot also works fine (like all VS Code plugins). I have a separate terminal window open where I (re)start HA when needed. All my files are in WSL, there is nothing local.

Hello,

I just wanted to create a thread by myself for exactly this use case. Glad I checked the existing threads before.

I can answer the “why run it on a server instead of the local windows machine” question: When using windows and wsl it is impossible to include some external usb peripherals (like the ble stick). Thats why I want to run it on proxmox (with attached ble usb stick) and debug from my windows pc and VSC.

Ah yes, accessing USB devices from WSL is a problem.

There is this method using USBIPD, but I personally never tried it because it looked complicated Connect USB devices | Microsoft Learn

I don’t know about BLE development myself, but I have seen recommendations of using an ESP-Home bluetooth proxy for development instead of using bluetooth dongles on the development machine. Those proxies are connected over IP so it is easy to use from anywhere. I don’t know if that works for your case.

If you need to access a USB device that is a serial port then you could forward it over TCP/IP. I made this integration to help with that GitHub - mvdwetering/network_serial_port: TCP to serial integration for Home Assistant (repo is HACS compatible so you can just add the URL)

To use it I disable the original integration that is using the USB serial port.
Then confgiure the network_serial_port integration to use the USB serial port. After that on my development machine connect to the TCP port exposed by the network_serial_port integration.

In my case the integration I was debugging was using PySerial so I could just use socket://<ha-ip>:<port> format to access the serial port. Otherwise you can convert the TCP port into a serial device with socat magic

When done disable network_serial_port integration and enable the original integration again.
While not super convenient this worked well enough for me to do some debugging with the Plugwise stick that was in my HAOS machine.