Skip to content

Commit

Permalink
Merge pull request #1058 from KartoffelToby/feature/development
Browse files Browse the repository at this point in the history
Feature/development
  • Loading branch information
KartoffelToby authored Sep 20, 2023
2 parents efdb7f8 + ea675d8 commit 4c129a8
Show file tree
Hide file tree
Showing 12 changed files with 109 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,6 @@ template:


# If you need to debug uncomment the line below (doc: https://www.home-assistant.io/integrations/debugpy/)
#debugpy:
debugpy:


11 changes: 8 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
"image": "mcr.microsoft.com/devcontainers/python:0-3.11",
"name": "BETTER THERMOSTAT development",
"initializeCommand": "/bin/mkdir -p ${localWorkspaceFolder}/.haconfig && /bin/cp ${localWorkspaceFolder}/.devcontainer/configuration.yaml ${localWorkspaceFolder}/.haconfig",
"containerUser": "1000",
"remoteUser": "1000",
"appPort": [
"9123:8123"
],
"forwardPorts": [
9123
],
"portsAttributes": {
"8123": {
"9123": {
"label": "HomeAssistant port",
"protocol": "http",
"onAutoForward": "notify"
Expand Down Expand Up @@ -39,8 +44,8 @@
]
}
},
"postCreateCommand": "pip install -r requirements.dev.txt",
"postCreateCommand": "scripts/setup",
"mounts": [
"source=${localWorkspaceFolder}/.haconfig,target=/config,type=bind,consistency=cached"
]
}
}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ venv
.idea
custom_components/hacs
x_*
.haconfig
.haconfig
6 changes: 4 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
"request": "launch",
"module": "homeassistant",
"args": [
"--debug",
"-c",
"/config"
],
"justMyCode": true
}
"justMyCode": false,
"console": "internalConsole"
},
]
}
10 changes: 5 additions & 5 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
{
"label": "Run Home Assistant on port 9123",
"type": "shell",
"command": "container start",
"command": "scripts/start",
"problemMatcher": []
},
{
"label": "Run Home Assistant configuration against /config",
"label": "Sync configuration.yaml (Override local)",
"type": "shell",
"command": "container check",
"command": "scripts/sync",
"problemMatcher": []
},
{
"label": "Upgrade Home Assistant to latest dev",
"type": "shell",
"command": "container install",
"command": "scripts/upgrade-dev",
"problemMatcher": []
},
{
"label": "Install a specific version of Home Assistant",
"type": "shell",
"command": "container set-version",
"command": "scripts/upgrade-version",
"problemMatcher": []
}
]
Expand Down
23 changes: 23 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,29 @@
The following is a set of guidelines for contributing to Better Thermostat. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this
document in a pull request.

## Development

#### Requirements
- VSCode
- Docker
- Devcontainer Extension

#### Setup
1. Clone the repository
2. Open the repository in VSCode
3. Click on the green button in the bottom left corner and select "Reopen in Container"
4. Wait for the container to build
5. Open Task Runner and run "Run Home Assistant on port 9123"
6. Open the browser and go to http://localhost:9123 -> Inital DEV HA Setup


#### Nice to know

- Debuging is possible with the VSCode Debuger. Just run the HomeAssistant in Debugger and open browser on http://localhost:9123 (No task run needed)
- Update your local in devcontainer configuration.yaml to the current version of the repository to get the latest changes. -> Run "Sync configuration.yaml (Override local)" in Task Runner
- Test BT in a specific HA version -> Run "Install a specific version of Home Assistant" in Task Runner and the the version you want to test in the terminal promt.
- Test BT with the latest HA version -> Run "pgrade Home Assistant to latest dev" in Task Runner

## How Can I Contribute?

## New Adapter
Expand Down
8 changes: 7 additions & 1 deletion requirements.dev.txt
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
homeassistant==2023.9.2
homeassistant==2023.9.2
pre-commit==2.15.0
black==23.9.1
codespell==2.2.2
ruff==0.0.289
yamllint==1.32.0
flake8==4.0.1
7 changes: 7 additions & 0 deletions scripts/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

set -e

cd "$(dirname "$0")/.."

python3 -m pip install --requirement requirements.dev.txt
20 changes: 20 additions & 0 deletions scripts/start
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}/.haconfig" ]]; then
mkdir -p "${PWD}/.haconfig"
hass --config "${PWD}/.haconfig" --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}/.haconfig" --debug
11 changes: 11 additions & 0 deletions scripts/sync
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

set -e

cd "$(dirname "$0")/.."

echo "Syncing configuration.yaml"

cp -f .devcontainer/configuration.yaml ${PWD}/.haconfig/configuration.yaml

echo "Done. Restart Home Assistant to see changes."
9 changes: 9 additions & 0 deletions scripts/upgrade-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -e

cd "$(dirname "$0")/.."

python3 -m pip install homeassistant

echo "Done."
13 changes: 13 additions & 0 deletions scripts/upgrade-version
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

set -e

read -p "What HA Version? " VERSION
echo "Installing ${my_var}!"


cd "$(dirname "$0")/.."

python3 -m pip install homeassistant==$VERSION

echo "Done."

0 comments on commit 4c129a8

Please sign in to comment.