diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 6a96345..21d58d0 100755 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,32 +1,27 @@ // See https://aka.ms/vscode-remote/devcontainer.json for format details. { - "image": "ghcr.io/ludeeus/devcontainer/integration:stable", - "name": "Eight Sleep Climate integration development", - "context": "..", - "appPort": ["9123:8123"], - "postCreateCommand": ".devcontainer/setup.sh", - "mounts": [ - "source=${localEnv:HOME}${localEnv:USERPROFILE}/.gitconfig,target=/root/.gitconfig,type=bind,consistency=cached" - ], - "extensions": [ - "ms-python.python", - "github.vscode-pull-request-github", - "ryanluker.vscode-coverage-gutters", - "ms-python.vscode-pylance", - "esbenp.prettier-vscode" - ], - "settings": { - "files.eol": "\n", - "editor.tabSize": 4, - "terminal.integrated.shell.linux": "/bin/bash", - "python.pythonPath": "/usr/bin/python3", - "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 - } + "name": "Eight sleep climate integration development", + "image": "mcr.microsoft.com/devcontainers/python:3.11-bullseye", + "postStartCommand": "git config --global --add safe.directory ${containerWorkspaceFolder}", + "postAttachCommand": ".devcontainer/setup.sh", + "forwardPorts": [8123], + "portsAttributes": { + "8123": { + "label": "Home Assistant", + "onAutoForward": "notify" + } + }, + "customizations": { + "vscode": { + "extensions": [ + "esbenp.prettier-vscode", + "github.vscode-pull-request-github", + "ms-vscode-remote.remote-containers", + "ms-python.black-formatter", + "ms-python.vscode-pylance", + "ryanluker.vscode-coverage-gutters" + ] + } + }, + "remoteUser": "vscode" } diff --git a/.devcontainer/develop.sh b/.devcontainer/develop.sh new file mode 100755 index 0000000..89eda50 --- /dev/null +++ b/.devcontainer/develop.sh @@ -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 diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh index 63ddc49..593d5bd 100755 --- a/.devcontainer/setup.sh +++ b/.devcontainer/setup.sh @@ -6,7 +6,5 @@ set -e cd "$(dirname "$0")/.." -pip3 install -r .github/workflows/constraints.txt +pip3 install --requirement requirements.txt pre-commit install - -container install diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 15c7513..eee5550 100755 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -3,12 +3,11 @@ updates: - package-ecosystem: github-actions directory: "/" schedule: - interval: daily - - package-ecosystem: pip - directory: "/.github/workflows" - schedule: - interval: daily - - package-ecosystem: pip + interval: weekly + - package-ecosystem: "pip" directory: "/" schedule: - interval: daily + interval: weekly + ignore: + # Dependabot should not update Home Assistant as that should match the homeassistant key in hacs.json + - dependency-name: "homeassistant" diff --git a/.github/workflows/constraints.txt b/.github/workflows/constraints.txt deleted file mode 100644 index d4dfa33..0000000 --- a/.github/workflows/constraints.txt +++ /dev/null @@ -1,5 +0,0 @@ -pip==23.3.2 -pre-commit==3.6.2 -black==23.12.1 -flake8==6.1.0 -reorder-python-imports==3.12.0 diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index df1d91c..1ea02e5 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -19,21 +19,21 @@ jobs: name: Pre-commit steps: - name: Check out the repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python ${{ env.DEFAULT_PYTHON }} - uses: actions/setup-python@v4.8.0 + uses: actions/setup-python@v4.7.1 with: python-version: ${{ env.DEFAULT_PYTHON }} - name: Upgrade pip run: | - pip install --constraint=.github/workflows/constraints.txt pip + pip install --constraint=requirements.txt pip pip --version - name: Install Python modules run: | - pip install --constraint=.github/workflows/constraints.txt pre-commit black flake8 reorder-python-imports + pip install --constraint=requirements.txt pre-commit black flake8 reorder-python-imports - name: Run pre-commit on all files run: | @@ -44,7 +44,7 @@ jobs: name: HACS steps: - name: Check out the repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: HACS validation uses: hacs/action@main @@ -57,7 +57,7 @@ jobs: name: Hassfest steps: - name: Check out the repository - uses: "actions/checkout@v3" + uses: "actions/checkout@v4" - name: Hassfest validation uses: "home-assistant/actions/hassfest@master" diff --git a/.gitignore b/.gitignore index a4a4d84..b66d45d 100755 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,14 @@ +# artifacts __pycache__ -pythonenv* -.python-version +.pytest* +*.egg-info +*/build/* +*/dist/* + +# misc .coverage -venv -.venv +coverage.xml + +# Home Assistant configuration +config/* +!config/configuration.yaml diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100755 index cc5337a..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - // 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" - } - ] - } - ] -} diff --git a/.vscode/settings.json b/.vscode/settings.json index 2be6282..afb5357 100755 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,12 +1,20 @@ { - "python.linting.pylintArgs": ["--rcfile=setup.cfg"], - "python.linting.pylintEnabled": true, - "python.linting.enabled": true, - "python.pythonPath": "venv/bin/python", - "files.associations": { - "*.yaml": "home-assistant" + "analysis.autoSearchPaths": false, + "editor.codeActionsOnSave": { + "source.organizeImports": "explicit" }, + "editor.formatOnSave": true, + "editor.tabSize": 4, + "files.eol": "\n", + "files.trimTrailingWhitespace": true, + "terminal.integrated.shell.linux": "/bin/bash", "[javascript]": { "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[python]": { + "editor.defaultFormatter": "ms-python.black-formatter" + }, + "files.associations": { + "*.yaml": "home-assistant" } } diff --git a/.vscode/tasks.json b/.vscode/tasks.json index db41b54..46a87c8 100755 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -2,32 +2,14 @@ "version": "2.0.0", "tasks": [ { - "label": "Run Home Assistant on port 9123", + "label": "Run Home Assistant on port 8123", "type": "shell", - "command": "container start", + "command": ".devcontainer/develop.sh", "problemMatcher": [], "group": { "kind": "build", "isDefault": true } - }, - { - "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", - "problemMatcher": [] } ] } diff --git a/.devcontainer/configuration.yaml b/config/configuration.yaml old mode 100755 new mode 100644 similarity index 100% rename from .devcontainer/configuration.yaml rename to config/configuration.yaml diff --git a/requirements.txt b/requirements.txt new file mode 100755 index 0000000..42f7458 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,8 @@ +black==23.12.0 +colorlog==6.8.0 +flake8==6.1.0 +homeassistant==2023.6.0 +pip>=21.0,<23.2 +pre-commit==3.6.0 +reorder-python-imports==3.12.0 +ruff==0.1.11