Best practices to develop and maintain a custom component

I’ve few custom components that have their own repos in Github.
My current workflow is:

  1. I develop\modify the component in the test environment ( clone of core)
  2. When I’m done I copy the component into the component’s repo and push the changes
    2a. and I copy the component in production.

Is there a better way to do it? DO you have examples?

That’s pretty much how I have developed some custom components in the past.

Another option is to make your custom component repository compatible with HACS and deploy it through by adding it manually or publish it via HACS. (Example)

I’ve found this nice tutorial Building a Home Assistant Custom Component Part 1: Project Structure and Basics - Automate The Things

and also this Home Assistant custom component Cookiecutter — Home Assistant Custom Component Cookiecutter documentation from @oncleben31.


With my cookiecutter or using directly the Integration Blueprint you can manage the development of a custom component in a dedicated test environment, manage version controlling with git very fluently based on docker.

1 Like

I also recommend @oncleben31 suggestions. This allows you to get a testing instance setup to write tests, but how to get your custom component easily run live with user interaction? Here is what I do from the structure already mentioned by @oncleben31, but I’m also interested if there is a better way.

  1. Create a config folder in the base repo that is included in the .gitignore
  2. Create a soft link inside config to the custom_components folder, i.e. ln -s custom_components config/custom_components
  3. Run hass -c config

I would recommend you have homeassistant package installed (aka homeassistant/core, the naming is still really tough here) in a virtual environment, so you can keep your versions all neatly contained for this.