Skip to content

Commit

Permalink
fix: change structure to not override core
Browse files Browse the repository at this point in the history
This was required by home-assistant/wheels-custom-integrations#383 (comment)

Tesla in core will be non-functional regardless.
  • Loading branch information
alandtse committed Apr 30, 2021
1 parent bf34e49 commit f173b68
Show file tree
Hide file tree
Showing 53 changed files with 155 additions and 45 deletions.
60 changes: 60 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
## Developing with Visual Studio Code + devcontainer

The easiest way to get started with custom integration development is to use Visual Studio Code with devcontainers. This approach will create a preconfigured development environment with all the tools you need.

In the container you will have a dedicated Home Assistant core instance running with your custom component code. You can configure this instance by updating the `./devcontainer/configuration.yaml` file.

**Prerequisites**

- [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
- Docker
- For Linux, macOS, or Windows 10 Pro/Enterprise/Education use the [current release version of Docker](https://docs.docker.com/install/)
- Windows 10 Home requires [WSL 2](https://docs.microsoft.com/windows/wsl/wsl2-install) and the current Edge version of Docker Desktop (see instructions [here](https://docs.docker.com/docker-for-windows/wsl-tech-preview/)). This can also be used for Windows Pro/Enterprise/Education.
- [Visual Studio code](https://code.visualstudio.com/)
- [Remote - Containers (VSC Extension)][extension-link]

[More info about requirements and devcontainer in general](https://code.visualstudio.com/docs/remote/containers#_getting-started)

[extension-link]: https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers

**Getting started:**

1. Fork the repository.
2. Clone the repository to your computer.
3. Open the repository using Visual Studio code.

When you open this repository with Visual Studio code you are asked to "Reopen in Container", this will start the build of the container.

_If you don't see this notification, open the command palette and select `Remote-Containers: Reopen Folder in Container`._

### Tasks

The devcontainer comes with some useful tasks to help you with development, you can start these tasks by opening the command palette and select `Tasks: Run Task` then select the task you want to run.

When a task is currently running (like `Run Home Assistant on port 9123` for the docs), it can be restarted by opening the command palette and selecting `Tasks: Restart Running Task`, then select the task you want to restart.

The available tasks are:

| Task | Description |
| ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------- |
| Run Home Assistant on port 9123 | Launch Home Assistant with your custom component code and the configuration defined in `.devcontainer/configuration.yaml`. |
| Run Home Assistant configuration against /config | Check the configuration. |
| Upgrade Home Assistant to latest dev | Upgrade the Home Assistant core version in the container to the latest version of the `dev` branch. |
| Install a specific version of Home Assistant | Install a specific version of Home Assistant core in the container. |

### Step by Step debugging

With the development container,
you can test your custom component in Home Assistant with step by step debugging.

You need to modify the `configuration.yaml` file in `.devcontainer` folder
by uncommenting the line:

```yaml
# debugpy:
```

Then launch the task `Run Home Assistant on port 9123`, and launch the debbuger
with the existing debugging configuration `Python: Attach Local`.

For more information, look at [the Remote Python Debugger integration documentation](https://www.home-assistant.io/integrations/debugpy/).
11 changes: 11 additions & 0 deletions .devcontainer/configuration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
default_config:

logger:
default: info
logs:
homeassistant.setup: debug
custom_components.tesla_custom: debug
authcaptureproxy: debug
teslajsonpy: debug
# If you need to debug uncommment the line below (doc: https://www.home-assistant.io/integrations/debugpy/)
debugpy:
32 changes: 32 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"image": "ludeeus/container:integration-debian",
"name": "Tesla Custom Component development",
"context": "..",
"appPort": ["9123:8123"],
"postCreateCommand": "container install && pip install poetry && poetry config virtualenvs.create false && poetry install",
"extensions": [
"ms-python.python",
"github.vscode-pull-request-github",
"ryanluker.vscode-coverage-gutters",
"ms-python.vscode-pylance",
"littlefoxteam.vscode-python",
"bungcip.better-toml",
"redhat.vscode-yaml",
"eamodio.gitlens",
"littlefoxteam.vscode-python-test-adapter"
],
"settings": {
"files.eol": "\n",
"editor.tabSize": 4,
"terminal.integrated.shell.linux": "/bin/bash",
"python.pythonPath": "/usr/local/python/bin/python",
"python.analysis.autoSearchPaths": false,
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"python.formatting.provider": "black",
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true
}
}
2 changes: 1 addition & 1 deletion .github/workflows/pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
--timeout=9 \
--durations=10 \
-n auto \
--cov custom_components.tesla \
--cov custom_components.tesla_custom \
-o console_output_style=count \
-p no:sugar \
tests
2 changes: 1 addition & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
--timeout=9 \
--durations=10 \
-n auto \
--cov custom_components.tesla \
--cov custom_components.tesla_custom \
-o console_output_style=count \
-p no:sugar \
tests
4 changes: 2 additions & 2 deletions .github/workflows/semantic_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
github_token: ${{ secrets.GH_TOKEN }}
- name: Zip tesla dir
run: |
cd /home/runner/work/tesla/tesla/custom_components/tesla
cd /home/runner/work/tesla/tesla/custom_components/tesla_custom
zip tesla.zip -r ./
- name: Set release variable
run: |
Expand All @@ -67,7 +67,7 @@ jobs:
uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GH_TOKEN }}
file: /home/runner/work/tesla/tesla/custom_components/tesla/tesla.zip
file: /home/runner/work/tesla/tesla/custom_components/tesla_custom/tesla.zip
asset_name: tesla.zip
tag: ${{ env.release_version }}
overwrite: true
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ deps/deps.jl
!.npmignore
!/.scrutinizer.yml
!/.prospector.yml
!/.devcontainer
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ To the extent the official component adds features unrelated to the login, we wi
1. Use HACS after adding this `https://github.com/alandtse/tesla` as a custom repository. Skip to 7.
2. If no HACS, use the tool of choice to open the directory (folder) for your HA configuration (where you find `configuration.yaml`).
3. If you do not have a `custom_components` directory (folder) there, you need to create it.
4. In the `custom_components` directory (folder) create a new folder called `tesla`.
5. Download _all_ the files from the `custom_components/tesla/` directory (folder) in this repository.
4. In the `custom_components` directory (folder) create a new folder called `tesla_custom`.
5. Download _all_ the files from the `custom_components/tesla_custom/` directory (folder) in this repository.
6. Place the files you downloaded in the new directory (folder) you created.
7. Restart Home Assistant.
8. In the HA UI go to "Configuration" -> "Integrations" click "+" and search for "Tesla Custom Integration". If you are replacing core, remove the core integration before installing.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
VERSION = "0.1.0"
CONF_WAKE_ON_START = "enable_wake_on_start"
CONF_EXPIRATION = "expiration"
DOMAIN = "tesla"
DOMAIN = "tesla_custom"
DATA_LISTENER = "listener"
DEFAULT_SCAN_INTERVAL = 660
DEFAULT_WAKE_ON_START = False
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"domain": "tesla",
"domain": "tesla_custom",
"name": "Tesla Custom Integration",
"config_flow": true,
"documentation": "https://github.com/alandtse/tesla",
"issue_tracker": "https://github.com/alandtse/tesla/issues",
"requirements": ["teslajsonpy==0.18.0"],
"requirements": ["teslajsonpy~=0.18"],
"codeowners": ["@alandtse"],
"dependencies": ["http"],
"dhcp": [
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ teslajsonpy = "^0.17.1"

[tool.poetry.dev-dependencies]
homeassistant = "^2021.3.4"
pytest-homeassistant-custom-component = "0.1.0"
pytest-homeassistant-custom-component = "~0.3.0"
bandit = "^1.7.0"
black = {version = "^20.8b1", allow-prereleases = true}
mypy = "^0.812"
Expand All @@ -24,8 +24,8 @@ requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.semantic_release]
version_variable='pyproject.toml:version,custom_components/tesla/const.py:VERSION'
version_pattern='custom_components/tesla/manifest.json:"version": "{version}"'
version_variable='pyproject.toml:version,custom_components/tesla_custom/const.py:VERSION'
version_pattern='custom_components/tesla_custom/manifest.json:"version": "{version}"'
upload_to_pypi=false
upload_to_release=false
changelog_sections="feature,fix,breaking,documentation,performance,refactor"
Expand Down
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@ ignore_missing_imports = true
warn_incomplete_stub = true
warn_redundant_casts = true
warn_unused_configs = true
exclude=custom_components\/(?!tesla).*
2 changes: 1 addition & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"""Tests for Home Assistant."""
"""Tests for Tesla Custom Integration."""
Loading

0 comments on commit f173b68

Please sign in to comment.