diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 7b119f5..c74f2db 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,39 +1,36 @@ // See https://aka.ms/vscode-remote/devcontainer.json for format details. { - "image": "ghcr.io/ludeeus/devcontainer/integration:latest", + "image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye", "name": "ha-nest-protect", - "context": "..", - "appPort": [ - "8123:8123" - ], - "postCreateCommand": "container install && pip install -r requirements_dev.txt && pre-commit install && pre-commit install-hooks", - "extensions": [ - "ms-python.python", - "github.vscode-pull-request-github", - "github.copilot", - "ms-python.vscode-pylance" - ], - "settings": { - "files.eol": "\n", - "editor.tabSize": 4, - "terminal.integrated.defaultProfile.linux": "bash", - "terminal.integrated.profiles.linux": { - "zsh": { - "path": "/bin/bash" - } - }, - "python.analysis.autoSearchPaths": false, - "python.linting.pylintEnabled": true, - "python.linting.enabled": true, - "python.linting.pylintArgs": [ - "--disable", - "import-error" - ], - "python.formatting.provider": "black", - "editor.formatOnPaste": false, - "editor.formatOnSave": true, - "editor.formatOnType": true, - "files.trimTrailingWhitespace": true, - "python.linting.mypyEnabled": true, + "forwardPorts": [8123], + "portsAttributes": { + "8123": { + "label": "Home Assistant", + "onAutoForward": "openBrowserOnce" + } + }, + "postCreateCommand": "pip install -r requirements_dev.txt && pre-commit install && pre-commit install-hooks", + "containerEnv": { + "DEVCONTAINER": "1" + }, + "remoteUser": "vscode", + "customizations": { + "vscode": { + "extensions": [ + "ms-python.vscode-pylance", + "ms-python.python", + "redhat.vscode-yaml", + "esbenp.prettier-vscode", + "GitHub.vscode-pull-request-github", + "GitHub.copilot" + ], + "settings": { + "python.pythonPath": "/usr/local/bin/python", + "editor.formatOnPaste": false, + "editor.formatOnSave": true, + "editor.formatOnType": true, + "files.trimTrailingWhitespace": true + } + } } } diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 78fd3fd..e680e80 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -10,5 +10,5 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: '3.10' + python-version: '3.11' - uses: pre-commit/action@v3.0.0 diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 7ba7a32..3cba2e7 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -11,8 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.10'] - # python-version: ['3.10', '3.11'] + python-version: ['3.11'] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} diff --git a/.gitignore b/.gitignore index 995afa3..4a242fd 100644 --- a/.gitignore +++ b/.gitignore @@ -200,3 +200,7 @@ cython_debug/ .history .ionide +# Devcontainer +config +!.vscode/tasks.json +!.vscode/launch.json \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index 555a62b..f36db85 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,35 +1,15 @@ { - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - // Example of attaching to local debug server - "name": "Python: Attach Local", - "type": "python", - "request": "attach", - "port": 5678, - "host": "localhost", - "pathMappings": [ - { - "localRoot": "${workspaceFolder}", - "remoteRoot": "." - } - ] - }, - { - // Example of attaching to my production server - "name": "Python: Attach Remote", - "type": "python", - "request": "attach", - "port": 5678, - "host": "homeassistant.local", - "pathMappings": [ - { - "localRoot": "${workspaceFolder}", - "remoteRoot": "/usr/src/homeassistant" - } - ] - } - ] - } - \ No newline at end of file + "version": "0.2.0", + "configurations": [ + { + "name": "Home Assistant with Nest Protect", + "type": "python", + "request": "launch", + "python": "/usr/local/bin/python", + "module": "homeassistant", + "cwd": "${workspaceFolder}", + "justMyCode": false, + "args": ["--debug", "-c", "config"] + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 69377c5..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "python.linting.pylintEnabled": true, - "python.linting.enabled": true, - "python.pythonPath": "/usr/local/bin/python", - "files.associations": { - "*.yaml": "home-assistant" - }, - "python.formatting.provider": "black" -} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index d1a0ae7..36eb944 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -2,27 +2,9 @@ "version": "2.0.0", "tasks": [ { - "label": "Run Home Assistant on port 9123", + "label": "Run Home Assistant on port 8123", "type": "shell", - "command": "container start", - "problemMatcher": [] - }, - { - "label": "Run Home Assistant configuration against /config", - "type": "shell", - "command": "container check", - "problemMatcher": [] - }, - { - "label": "Upgrade Home Assistant to latest dev", - "type": "shell", - "command": "container install", - "problemMatcher": [] - }, - { - "label": "Install a specific version of Home Assistant", - "type": "shell", - "command": "container set-version", + "command": "bash scripts/run", "problemMatcher": [] } ] diff --git a/config/configuration.yaml b/config/configuration.yaml new file mode 100644 index 0000000..8feeb5f --- /dev/null +++ b/config/configuration.yaml @@ -0,0 +1,10 @@ +default_config: + +logger: + default: info + logs: + custom_components.nest_protect: debug + +# If you need to debug uncomment the line below (doc: https://www.home-assistant.io/integrations/debugpy/) + +# debugpy: diff --git a/hacs.json b/hacs.json index ea3e332..496ebe9 100644 --- a/hacs.json +++ b/hacs.json @@ -6,7 +6,7 @@ "select", "switch" ], - "homeassistant": "2023.1.7", + "homeassistant": "2023.8.2", "render_readme": "true", "iot_class": "Cloud Polling" } \ No newline at end of file diff --git a/requirements_dev.txt b/requirements_dev.txt index 6e2129f..c0a5767 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1,2 +1,2 @@ -homeassistant==2023.1.7 +homeassistant==2023.8.2 pre-commit \ No newline at end of file diff --git a/requirements_test.txt b/requirements_test.txt index 3df9eef..509105c 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,6 +1,6 @@ -r requirements_dev.txt -pytest==7.2.0 -pytest-socket==0.5.1 -pytest-homeassistant-custom-component==0.12.49 # 2023.1.7 +pytest==7.3.1 +pytest-socket==0.6.0 +pytest-homeassistant-custom-component==0.13.51 # 2023.8.2 pytest-timeout==2.1.0 \ No newline at end of file diff --git a/scripts/run b/scripts/run new file mode 100644 index 0000000..20366e8 --- /dev/null +++ b/scripts/run @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +# Create config dir if not present +if [[ ! -d "${PWD}/config" ]]; then + mkdir -p "${PWD}/config" + hass --config "${PWD}/config" --script ensure_config +fi + +# Set the path to custom_components +## This let's us have the structure we want /custom_components/integration_blueprint +## while at the same time have Home Assistant configuration inside /config +## without resulting to symlinks. +export PYTHONPATH="${PYTHONPATH}:${PWD}/custom_components" + +# Start Home Assistant +hass --config "${PWD}/config" --debug \ No newline at end of file