Developing/extending extension, best approach without dedicated dev system?

I would like to extend an existing integration. I will fork the git repo and after I am done adding everything, create a PR.

I have never developed for HA but I have programming experience. I do not want to spin up a dedicated dev system but just work with my normal install (HA OS + HACS).

Conceptually, what’s the best approach to do this?

  1. Do I directly “git clone” in the “custom_components” directory?
  2. I assume I need to remove the existing extension (from a custom HACS repository) first?
  3. Do I then edit the files in-place or do people edit on a host system and do “git pull”?
  4. In case of “in place” editing, how to do this best? “vi” works but it’s pretty cumbersome for me
  5. Especially at the beginning, there will be lots of iterations between editing files and trying them out. How do I make sure that my changes are applied? Is it sufficient to just reload the extension after each change?

Fork the original repository and then add the fork as a custom repository to HACS.

What constraint is in place that you don’t want a development environment? It’s easy to spin one up using vscode and devcontainers and will be a lot easier to work with.

My question is more about how to make changes to existing code (“develop”), how to see and verify the changes and how then push them back to the repository.

Because it’s really just a few lines of code that I want to change. I don’t want to spin up an entirely new developing platform for this.

As a matter of fact, right now I don’t even own a private PC any more. Just my work laptop and my servers. Can’t easily install stuff on my work laptop and doing all of this via a proxmox container/VM via ssh it’s a huge amount of effort for a couple of lines of code.

If you use a forked repository, you can just edit the files in the custom_components folder and then push them back up to Github.

You can use Home Assistant Community Add-on: Visual Studio Code to edit the files via a web browser. Thereby not needing to install anything on another machine.

Oh great. How would this work, just “git commit” and “git push” ?

Great, using this one already.

Last question is then:

No, I don’t think it works so easily

$  my_custom_forked_extension pwd            
/root/homeassistant/custom_components/my_custom_forked_extension
$  my_custom_forked_extension git status
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
$  my_custom_forked_extension

Sorry, I thought that was how I set-up some stuff ages ago. However, HACS uses a specific folder structure and hence you need to keep that intact. The way to do that is to use a symlink - create a /share/custom_components folder and clone the repo into that:

1). Clone the repo:

git clone https://github.com/gituser/forked_custom_component.git

2). Create a symlink

ln -s /share/custom_components/forked_custom_component/custom_components/foldername /config/custom_components/foldername