Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add development in container explanations #40

Merged
merged 1 commit into from
Nov 7, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Features
- Ready to use Home Assistant custom component
- UI configuration with config Flow
- Translations
- Development and testing in Visual Studio Code devcontainer
- Development and testing in Visual Studio Code development container
- HACS_ ready
- Continuous integration with `GitHub Actions`_

Expand Down Expand Up @@ -90,13 +90,15 @@ It is recommended to set up Python 3.7, 3.8, or 3.9 using pyenv_.
Creating a project
------------------

Generate a Home Assistant custom component project:
Generate a Home Assistant custom component project by using the following command
and setting the different parameters of the template:

.. code:: console

$ cookiecutter gh:oncleben31/cookiecutter-homeassistant-custom-component \
--checkout="2020.10.30"


Change to the root directory of your new project,
and create a Git repository:

Expand All @@ -107,7 +109,35 @@ and create a Git repository:
$ git commit


Setup the development container
-------------------------------

The development container allows to work in a local and dedicated Home Assitant instance
to test your custom component.
To launch it you need to have already installed Docker_, `Visual Studio Code`_ (VSC)
and the `Visual Studio Code Remote - Containers`_ extension.

Open your local copy of the repository with VSC:

.. code:: console

$ code .

Visual Studio Code starts and you are asked to "Reopen in Container",
this will start the build of the container.

When done, you can launch the local instance of Home Assistant by running the task ``Run Home Assistant on port 9123``.

Use your preferred browser to open the URL ``http://localhost:9123``.

Initalize your Home Assistant local instance by following the onboarding workflow.

When setup, you can go to **Configuration** -> **Integrations** menu, clic the ``+`` button
and search the name you have given to the custom component.

Follow the config flow of the custom component to integrate it in Home Assistant.

Now you are all set to modify the code and develop your ideas !

.. quickstart-end

Expand All @@ -119,6 +149,7 @@ and create a Git repository:
.. _cookiecutter-homeassistant-component: https://github.com/boralyl/cookiecutter-homeassistant-component
.. _cookiecutter-homeassistant-custom-component-instance: https://github.com/oncleben31/cookiecutter-homeassistant-custom-component-instance
.. _cookiecutter-hypermodern-python: https://github.com/cjolowicz/cookiecutter-hypermodern-python
.. _Docker: https://www.docker.com/
.. _GitHub: https://github.com/
.. _GitHub Actions: https://github.com/features/actions
.. _HACS: https://hacs.xyz/
Expand All @@ -128,5 +159,7 @@ and create a Git repository:
.. _pipx: https://pipxproject.github.io/pipx/
.. _pre-commit: https://pre-commit.com/
.. _pyenv: https://github.com/pyenv/pyenv
.. _Visual Studio Code: https://code.visualstudio.com/
.. _Visual Studio Code Remote - Containers: https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers

.. references-end