Skip to content

Commit cf7a899

Browse files
committed
Initial commit
0 parents  commit cf7a899

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1671
-0
lines changed

.devcontainer/README.md

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
## Developing with Visual Studio Code + devcontainer
2+
3+
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.
4+
5+
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.
6+
7+
**Prerequisites**
8+
9+
- [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
10+
- Docker
11+
- For Linux, macOS, or Windows 10 Pro/Enterprise/Education use the [current release version of Docker](https://docs.docker.com/install/)
12+
- 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.
13+
- [Visual Studio code](https://code.visualstudio.com/)
14+
- [Remote - Containers (VSC Extension)][extension-link]
15+
16+
[More info about requirements and devcontainer in general](https://code.visualstudio.com/docs/remote/containers#_getting-started)
17+
18+
[extension-link]: https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers
19+
20+
**Getting started:**
21+
22+
1. Fork the repository.
23+
2. Clone the repository to your computer.
24+
3. Open the repository using Visual Studio code.
25+
26+
When you open this repository with Visual Studio code you are asked to "Reopen in Container", this will start the build of the container.
27+
28+
_If you don't see this notification, open the command palette and select `Remote-Containers: Reopen Folder in Container`._
29+
30+
### Tasks
31+
32+
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.
33+
34+
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.
35+
36+
The available tasks are:
37+
38+
Task | Description
39+
-- | --
40+
Run Home Assistant on port 9123 | Launch Home Assistant with your custom component code and the configuration defined in `.devcontainer/configuration.yaml`.
41+
Run Home Assistant configuration against /config | Check the configuration.
42+
Upgrade Home Assistant to latest dev | Upgrade the Home Assistant core version in the container to the latest version of the `dev` branch.
43+
Install a specific version of Home Assistant | Install a specific version of Home Assistant core in the container.
44+
45+
### Step by Step debugging
46+
47+
With the development container,
48+
you can test your custom component in Home Assistant with step by step debugging.
49+
50+
You need to modify the `configuration.yaml` file in `.devcontainer` folder
51+
by uncommenting the line:
52+
53+
```yaml
54+
# debugpy:
55+
```
56+
57+
Then launch the task `Run Home Assistant on port 9123`, and launch the debbuger
58+
with the existing debugging configuration `Python: Attach Local`.
59+
60+
For more information, look at [the Remote Python Debugger integration documentation](https://www.home-assistant.io/integrations/debugpy/).

.devcontainer/configuration.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
default_config:
2+
3+
logger:
4+
default: info
5+
logs:
6+
custom_components.integration_blueprint: debug
7+
8+
# If you need to debug uncommment the line below (doc: https://www.home-assistant.io/integrations/debugpy/)
9+
# debugpy:

.devcontainer/devcontainer.json

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// See https://aka.ms/vscode-remote/devcontainer.json for format details.
2+
{
3+
"image": "ludeeus/container:integration-debian",
4+
"name": "Blueprint integration development",
5+
"context": "..",
6+
"appPort": [
7+
"9123:8123"
8+
],
9+
"postCreateCommand": "container install",
10+
"extensions": [
11+
"ms-python.python",
12+
"github.vscode-pull-request-github",
13+
"ryanluker.vscode-coverage-gutters",
14+
"ms-python.vscode-pylance"
15+
],
16+
"settings": {
17+
"files.eol": "\n",
18+
"editor.tabSize": 4,
19+
"terminal.integrated.shell.linux": "/bin/bash",
20+
"python.pythonPath": "/usr/bin/python3",
21+
"python.analysis.autoSearchPaths": false,
22+
"python.linting.pylintEnabled": true,
23+
"python.linting.enabled": true,
24+
"python.formatting.provider": "black",
25+
"editor.formatOnPaste": false,
26+
"editor.formatOnSave": true,
27+
"editor.formatOnType": true,
28+
"files.trimTrailingWhitespace": true
29+
}
30+
}

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
5+
---
6+
7+
**Is your feature request related to a problem? Please describe.**
8+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
9+
10+
**Describe the solution you'd like**
11+
A clear and concise description of what you want to happen.
12+
13+
**Describe alternatives you've considered**
14+
A clear and concise description of any alternative solutions or features you've considered.
15+
16+
**Additional context**
17+
Add any other context or screenshots about the feature request here.

.github/ISSUE_TEMPLATE/issue.md

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
name: Issue
3+
about: Create a report to help us improve
4+
5+
---
6+
7+
<!-- Before you open a new issue, search through the existing issues to see if others have had the same problem.
8+
9+
Issues not containing the minimum requirements will be closed:
10+
11+
- Issues without a description (using the header is not good enough) will be closed.
12+
- Issues without debug logging will be closed.
13+
- Issues without configuration will be closed
14+
15+
-->
16+
17+
## Version of the custom_component
18+
<!-- If you are not using the newest version, download and try that before opening an issue
19+
If you are unsure about the version check the const.py file.
20+
-->
21+
22+
## Configuration
23+
24+
```yaml
25+
26+
Add your logs here.
27+
28+
```
29+
30+
## Describe the bug
31+
A clear and concise description of what the bug is.
32+
33+
34+
## Debug log
35+
36+
<!-- To enable debug logs check this https://www.home-assistant.io/components/logger/ -->
37+
38+
```text
39+
40+
Add your logs here.
41+
42+
```

.github/workflows/cron.yaml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Cron actions
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *'
6+
7+
jobs:
8+
validate:
9+
runs-on: "ubuntu-latest"
10+
name: Validate
11+
steps:
12+
- uses: "actions/checkout@v2"
13+
14+
- name: HACS validation
15+
uses: "hacs/action@main"
16+
with:
17+
category: "integration"
18+
ignore: brands
19+
20+
- name: Hassfest validation
21+
uses: "home-assistant/actions/hassfest@master"

.github/workflows/pull.yml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Pull actions
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
validate:
8+
runs-on: "ubuntu-latest"
9+
name: Validate
10+
steps:
11+
- uses: "actions/checkout@v2"
12+
13+
- name: HACS validation
14+
uses: "hacs/action@main"
15+
with:
16+
category: "integration"
17+
ignore: brands
18+
19+
- name: Hassfest validation
20+
uses: "home-assistant/actions/hassfest@master"
21+
22+
style:
23+
runs-on: "ubuntu-latest"
24+
name: Check style formatting
25+
steps:
26+
- uses: "actions/checkout@v2"
27+
- uses: "actions/setup-python@v1"
28+
with:
29+
python-version: "3.x"
30+
- run: python3 -m pip install black
31+
- run: black .
32+
33+
tests:
34+
runs-on: "ubuntu-latest"
35+
name: Run tests
36+
steps:
37+
- name: Check out code from GitHub
38+
uses: "actions/checkout@v2"
39+
- name: Setup Python
40+
uses: "actions/setup-python@v1"
41+
with:
42+
python-version: "3.8"
43+
- name: Install requirements
44+
run: python3 -m pip install -r requirements_test.txt
45+
- name: Run tests
46+
run: |
47+
pytest \
48+
-qq \
49+
--timeout=9 \
50+
--durations=10 \
51+
-n auto \
52+
--cov custom_components.integration_blueprint \
53+
-o console_output_style=count \
54+
-p no:sugar \
55+
tests

.github/workflows/push.yml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Push actions
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- dev
8+
9+
jobs:
10+
validate:
11+
runs-on: "ubuntu-latest"
12+
name: Validate
13+
steps:
14+
- uses: "actions/checkout@v2"
15+
16+
- name: HACS validation
17+
uses: "hacs/action@main"
18+
with:
19+
category: "integration"
20+
ignore: brands
21+
22+
- name: Hassfest validation
23+
uses: "home-assistant/actions/hassfest@master"
24+
25+
style:
26+
runs-on: "ubuntu-latest"
27+
name: Check style formatting
28+
steps:
29+
- uses: "actions/checkout@v2"
30+
- uses: "actions/setup-python@v1"
31+
with:
32+
python-version: "3.x"
33+
- run: python3 -m pip install black
34+
- run: black .
35+
36+
tests:
37+
runs-on: "ubuntu-latest"
38+
name: Run tests
39+
steps:
40+
- name: Check out code from GitHub
41+
uses: "actions/checkout@v2"
42+
- name: Setup Python
43+
uses: "actions/setup-python@v1"
44+
with:
45+
python-version: "3.8"
46+
- name: Install requirements
47+
run: python3 -m pip install -r requirements_test.txt
48+
- name: Run tests
49+
run: |
50+
pytest \
51+
-qq \
52+
--timeout=9 \
53+
--durations=10 \
54+
-n auto \
55+
--cov custom_components.integration_blueprint \
56+
-o console_output_style=count \
57+
-p no:sugar \
58+
tests

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
__pycache__
2+
pythonenv*
3+
venv
4+
.venv
5+
.coverage
6+
.idea

.vscode/launch.json

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
3+
"version": "0.2.0",
4+
"configurations": [
5+
{
6+
// Example of attaching to local debug server
7+
"name": "Python: Attach Local",
8+
"type": "python",
9+
"request": "attach",
10+
"port": 5678,
11+
"host": "localhost",
12+
"pathMappings": [
13+
{
14+
"localRoot": "${workspaceFolder}",
15+
"remoteRoot": "."
16+
}
17+
]
18+
},
19+
{
20+
// Example of attaching to my production server
21+
"name": "Python: Attach Remote",
22+
"type": "python",
23+
"request": "attach",
24+
"port": 5678,
25+
"host": "homeassistant.local",
26+
"pathMappings": [
27+
{
28+
"localRoot": "${workspaceFolder}",
29+
"remoteRoot": "/usr/src/homeassistant"
30+
}
31+
]
32+
}
33+
]
34+
}
35+

.vscode/settings.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"python.linting.pylintEnabled": true,
3+
"python.linting.enabled": true,
4+
"python.pythonPath": "/usr/local/bin/python",
5+
"files.associations": {
6+
"*.yaml": "home-assistant"
7+
}
8+
}

.vscode/tasks.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "Run Home Assistant on port 9123",
6+
"type": "shell",
7+
"command": "container start",
8+
"problemMatcher": []
9+
},
10+
{
11+
"label": "Run Home Assistant configuration against /config",
12+
"type": "shell",
13+
"command": "container check",
14+
"problemMatcher": []
15+
},
16+
{
17+
"label": "Upgrade Home Assistant to latest dev",
18+
"type": "shell",
19+
"command": "container install",
20+
"problemMatcher": []
21+
},
22+
{
23+
"label": "Install a specific version of Home Assistant",
24+
"type": "shell",
25+
"command": "container set-version",
26+
"problemMatcher": []
27+
}
28+
]
29+
}

0 commit comments

Comments
 (0)