2024-08-09 17:56:34 -05:00
2024-08-09 17:54:20 -05:00
2024-05-04 21:54:37 -05:00
2024-02-21 21:23:05 -06:00
2024-08-09 17:56:34 -05:00

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.

{
    // 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

#!/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)
  • AppManagement.check_app_updates
    • AppManagement._load_reload_modules
    • AppManagement._load_apps
      • AppManagement.init_object
Description
Dev config directory for AppDaemon development
Readme 82 KiB
Languages
Jupyter Notebook 80.8%
Python 19.2%