diff --git a/.gitignore b/.gitignore index ff8f85b..7f63403 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ .DS_Store __pycache__/ *.pyc +logs/ +apps/data/ diff --git a/.vscode/launch.json b/.vscode/launch.json index 65a39ae..777634b 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,6 +4,22 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ + { + "name": "Attach to AppDaemon", + "type": "debugpy", + "request": "attach", + "connect": { + "host": "localhost", + "port": 5678 + }, + "pathMappings": [ + { + "localRoot": "${workspaceFolder}", + "remoteRoot": "/conf" + } + ], + "justMyCode": true + }, { "name": "Run Unit Tests", "type": "debugpy", diff --git a/apps/apps.yaml b/apps/apps.yaml index cd40adf..a56299e 100644 --- a/apps/apps.yaml +++ b/apps/apps.yaml @@ -1,3 +1,8 @@ +debugger: + module: debugger + class: Debugger + port: 5678 + motion_tracker: module: motiontracker class: MotionTracker diff --git a/apps/debugger.py b/apps/debugger.py new file mode 100644 index 0000000..85d53b5 --- /dev/null +++ b/apps/debugger.py @@ -0,0 +1,12 @@ +import appdaemon.plugins.hass.hassapi as hass +import debugpy + + +class Debugger(hass.Hass): + def initialize(self): + port = int(self.args.get("port", 5678)) + try: + debugpy.listen(("0.0.0.0", port)) + self.log(f"debugpy listening on port {port}") + except RuntimeError: + self.log("debugpy already listening, skipping")