From e77f28c7f1f00b50ed0beb4d32160b64e025c0e7 Mon Sep 17 00:00:00 2001 From: Ashley Gittins Date: Thu, 9 May 2024 18:10:38 +0000 Subject: [PATCH] chore (ide): Fix debugging setup for vscode --- .vscode/launch.json | 34 ++++++++++++++++++++++------------ scripts/develop | 10 ++++++++++ 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 7686c31..add6d30 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -3,21 +3,31 @@ "version": "0.2.0", "configurations": [ { - "name": "Python Debugger: Remote Attach", + "name": "HomeAssistant(debug)", "type": "debugpy", - "request": "attach", - "connect": { - "host": "localhost", - "port": 5678 - }, + "request": "launch", "justMyCode": false, - "pathMappings": [ - { - "localRoot": "${workspaceFolder}", - "remoteRoot": "." - } - ] + "module": "homeassistant", + "args": ["--debug", "-c", "config"] }, + // This is the old (attempted) config of attaching to an already-running + // instance, but I couldn't get breakpoints to work in the custom_component. + // { + // "name": "Python Debugger: Remote Attach", + // "type": "debugpy", + // "request": "attach", + // "connect": { + // "host": "localhost", + // "port": 5678 + // }, + // "justMyCode": false, + // "pathMappings": [ + // { + // "localRoot": "${workspaceFolder}", + // "remoteRoot": "." + // } + // ] + // }, { // Example of attaching to my production server "name": "Python: Attach Remote", diff --git a/scripts/develop b/scripts/develop index 13d7e18..4451137 100755 --- a/scripts/develop +++ b/scripts/develop @@ -2,6 +2,12 @@ set -e +# #### Oh, hey... +# If you're using vscode, rather than using this I'd +# suggest running the debugger directly. As of now there's +# a working(!) debugpy entry in launch.json (just hit F5) + + cd "$(dirname "$0")/.." #if [[ ! -f venv/bin/activate ]]; then @@ -22,6 +28,10 @@ fi ## 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. +# +# Meh.. this used to work with the python extensions built-in debugger, +# but that's deprecated and the below didn't seem to work with the +# debugpy extension. Instead don't use this script and just hit F5. export PYTHONPATH="${PYTHONPATH}:${PWD}/custom_components" # Start Home Assistant