Skip to content

Commit

Permalink
Update devcontainer to Python 3.11 and bump to Home Assistant 2023.8.2 (
Browse files Browse the repository at this point in the history
  • Loading branch information
iMicknl authored Aug 13, 2023
1 parent 72cdce6 commit e7731e6
Show file tree
Hide file tree
Showing 12 changed files with 88 additions and 105 deletions.
65 changes: 31 additions & 34 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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
}
}
}
}
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 1 addition & 2 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,7 @@ cython_debug/
.history
.ionide

# Devcontainer
config
!.vscode/tasks.json
!.vscode/launch.json
48 changes: 14 additions & 34 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
]
}

"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"]
}
]
}
9 changes: 0 additions & 9 deletions .vscode/settings.json

This file was deleted.

22 changes: 2 additions & 20 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": []
}
]
Expand Down
10 changes: 10 additions & 0 deletions config/configuration.yaml
Original file line number Diff line number Diff line change
@@ -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:
2 changes: 1 addition & 1 deletion hacs.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"select",
"switch"
],
"homeassistant": "2023.1.7",
"homeassistant": "2023.8.2",
"render_readme": "true",
"iot_class": "Cloud Polling"
}
2 changes: 1 addition & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
homeassistant==2023.1.7
homeassistant==2023.8.2
pre-commit
6 changes: 3 additions & 3 deletions requirements_test.txt
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions scripts/run
Original file line number Diff line number Diff line change
@@ -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 <root>/custom_components/integration_blueprint
## while at the same time have Home Assistant configuration inside <root>/config
## without resulting to symlinks.
export PYTHONPATH="${PYTHONPATH}:${PWD}/custom_components"

# Start Home Assistant
hass --config "${PWD}/config" --debug

0 comments on commit e7731e6

Please sign in to comment.