Debug Appdaemon with Studio code server

I’m trying to debug Ad scripts using something better than simple log.

I have a rpi4 8gb with hassOS, the AD add-on and also Studio Code One. I tried to setup the debug system, but I failed.

I tried to setup this way

system_packages: []
python_packages:
  - debugpy
init_commands:
  - python3 -m debugpy --listen 0.0.0.0:5678 -m appdaemon

but I have errors.

ERROR: Error accessing configuration: No valid configuration file found in default locations: [‘/root/.homeassistant’, ‘/etc/appdaemon’, ‘/conf’]
[18:46:07] FATAL: Failed executing init command: python3 -m debugpy --listen 0.0.0.0:5678 -m appdaemon
s6-rc: warning: unable to start service init-appdaemon: command exited 1

I also tried to skip the init command and setting

debugpy.listen((“0.0.0.0”, 5678 ))

but when I try to connect to it using this launch.json

{
   "version": "0.2.0",
   "configurations": [
   {
      "name": "Attach to AppDaemon",
      "type": "debugpy",
      "request": "attach",
      "connect": {
      "host": "homeassistant.local",
      "port": 5678
      },
      "justMyCode": true
   }
   ]
}

It can’t connect

Do you know what I could try or how to set it up?

Thanks

I’m trying to open a port to the AD docker container, but under the Network tab I can only set the webServer port, not others.
I can’t edit the yaml for that section, so I suppose I can’t connect the debugger.

Thanks

Using this command AD can start

python3 -m debugpy --listen 0.0.0.0:5678 -m appdaemon -c /config

But I can’t connect since port 5678 is not exposed from docker.