Files
ad-dev-conf/README.md
2024-08-09 17:56:34 -05:00

80 lines
1.8 KiB
Markdown

# AppDaemon Dev
## Setup
### Secrets
Needs a long-lived token for HA in `secrets.yaml`
### Debugger
Use with VSCode's debugger using a `launch.json` file.
```json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "AppDaemon Dev",
"type": "debugpy",
"request": "launch",
"module": "appdaemon",
"justMyCode": true,
"args": "-c ../conf" // Expects the conf directory to be next to the appdaemon one
},
{
"name": "Pytest",
"type": "debugpy",
"request": "launch",
"module": "pytest",
"justMyCode": true,
"args": [
"${workspaceFolder}/tests",
"--maxfail=1", // Stop after the first failure
"-s" // Allow for interactive debugging (pdb)
],
}
]
}
```
### Test Script
```bash
#!/bin/bash
set -e
SCRIPT_DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}"))
REPO_DIR=$(dirname $SCRIPT_DIR)
echo $REPO_DIR
cd $REPO_DIR
rm -rf ./dist
# isort ./appdaemon ./docs/conf.py
black ./appdaemon ./docs/conf.py
pre-commit run --all-files
python -m pytest
python -m build
docker build -t appdaemon:local-dev .
cd ../conf
docker compose run -it --rm appdaemon
```
## Reference
- [`importlib.reload(module)`](https://docs.python.org/3/library/importlib.html#importlib.reload)
- `AppManagement.check_app_updates`
- `AppManagement._load_reload_modules`
- `AppManagement._load_apps`
- `AppManagement.init_object`