Skip to content

Instantly share code, notes, and snippets.

@cgtobi
Last active April 23, 2019 18:30
Show Gist options
  • Save cgtobi/676aa5f95aea915c8f6dfdac9d8ee4e0 to your computer and use it in GitHub Desktop.
Save cgtobi/676aa5f95aea915c8f6dfdac9d8ee4e0 to your computer and use it in GitHub Desktop.
Remote debugging Home Assistant with VSCode

Prerequisits

Local machine

  • Python 3 environment
  • VSCode 1.33.1 with Python 2019.3.6558
  • sshfs

Remote machine

  • Full development environment for Home Assistant
  • ptvsd

Prepare connections

Open tunnel to remote host in the background

ssh -f -p 9922 ubuntu@your.domain.tld -L 2222:dev.home.network:22 -N

SSHFS to remote host

mkdir remote_dev

sshfs -p 2222 ubuntu@localhost: ./remote_dev

VSCode

Open tunnel to remote host in the background

ssh -f -p 9922 ubuntu@your.domain.tld -L 3000:dev.home.network:3000 -N

Remote debugger config

{
    "name": "Python (Remote Debug) HA@dev",
    "type": "python",
    "request": "attach",
            "localRoot": "${workspaceRoot}/remote_dev/home-assistant",
    "remoteRoot": "/home/ubuntu/home-assistant",
    "port": 3000,
    "secret": "my_secret",
    "host":"localhost"
}

Connecting the debugger

python -m ptvsd --host dev.home.network --port 3000 --wait venv_37/bin/hass

Debugging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment