Debugging in appdaemon

Is it possible to debug inspect set breakpoints etc in some way?

You probably can although I haven’t tried it myself. When I need to do this, I run the AD app through the debugger in vscode on a local instance of AD. Feel free to try it out and let us know the outcome.

@proggie I am trying to do exactly that but without success so far.
What I did:
Installed locally appdaemon (no docker or venv, direct install via pip)
stopped production appdaemon docker (add-on)
started local appdaemon (connecting to my ha)

I can see from the logs that appdaemon local install is alive and well.
I tried to debug the hallo world app in vscode but an error is issued:

/usr/local/bin/python3 /Users/editeduser/appdaemon/apps/hello.py
(base) editeduser@Air-di-editeduser appdaemon % /usr/local/bin/python3 /User
s/editeduser/appdaemon/apps/hello.py
Traceback (most recent call last):
  File "/Users/editeduser/appdaemon/apps/hello.py", line 1, in <module>
    import appdaemon.plugins.hass.hassapi as hass
ModuleNotFoundError: No module named 'appdaemon'
(base) editeduser@Air-di-editeduser appdaemon % 

btw the error makes also sense to me : how do I make VS Code “aware” of the running environment of appdaemon? (i.e. of appdaemon modules location etc)

I tried to attach to the local executing appdaemon process via it’s processId but no success

TX

Maybe just try import hass although my setup is a bit different. I do use a venv with the dev branch but not installed with pip and I develop my applications using the import adbase method. You’ll also want to make sure the launch.json configuration is setup to properly run the appdaemon module. Here is an example.

{
    // 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": "Python: Module",
            "type": "python",
            "request": "launch",
            "module": "appdaemon",
            "args": [
                "-c",
                "c:/users/justin/projects/appdaemon_dev/conf",
                "-D",
                "INFO"
            ]
        }
    ]
}
2 Likes