Tutorial for creating a custom component

Once I add config flow to my integration, I can rename entities through the GUI. However the names reset when I restart Home Assistant. How can I prevent this?

Oh I see, problem was that I was just restarting the Home Assistant Dev Container, and so I guess Home Assistant just didnā€™t have time to save my updates. I chose Stop Server in the UI before restarting the Dev Container and it worked. :smiley:

1 Like

Thanks for the article. Glad something to gude to get started. I have HA green device. I am assuming that I login to terminal (not Docker home assistant) and change folder to custom_components and run pip to install cookie cutter template. Please let me know otherwise.

It would be much easier developing your custom component by running the devcontainer in vs-code from the core repository. Then creating a config/custom_components directory in that checked-out repository. It will be much faster to spin up and restart as you make changes.

To create the initial structure, Iā€™d just create a virtualenv on your local machine, activate it, pip install cookiecutter, then use cookiecutter to create your project template.

1 Like

Do you manually copy custom component into the devcontainer? Is there a way to sync the custom component repo to the devcontainer?

The config directory will be mounted into the devcontainer so you shouldnā€™t need to sync anything.

So, if you have the core repo checked out and create a config directory at the root and a custom_components directory within the config directory then you can edit files there and HA will see the custom component. Note you will have to restart the devcontainer when making changes to the python files.

example: /path/to/core/config/custom_components/tutorial if your custom component is named tutorial and exists in a directory at this location.

Got it, thanks.