jmcollin
(Jean-Marc COLLIN)
January 27, 2023, 11:24am
1
Hello,
I’m strugling for many days with the debug of my custom integration.
My config is the following:
I’ve added this config in my configuration.yaml:
debugpy:
start: true
wait: false
port: 5678
I’ve added this piece of config in launch.json:
{
// Example of attaching to local debug server
"name": "Python: Attach Local",
"type": "python",
"request": "attach",
"port": 5678,
"host": "localhost",
"justMyCode": false,
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "."
},
{
"localRoot": "${workspaceFolder}/custom_component/versatile_thermostat",
"remoteRoot": "/config/custom_component/versatile_thermostat"
}
]
},
I run hass (start devcontainer) and it starts fine, my custom integration is visible,
I attach the debugger by clicking here . I see some thread and stack trace so I should be operational,
I add some breakpoint but the execution never stop in my breakpoints whereever I put it (in my specific code or in HA legacy code.
Any would be appreciated.
Maybe my problem is that I’m running HA with the Ludeeus blueprint integration. I don’t know exactly how it works.
Note: I have read many post on this subject without success:
Rebuilding the dev container and running python3 -m script.hassfest has solved the problems.
Solved. Here’s what helped: (thanks to discord: @balloob )
Open Docker Desktop and check the container’s url by clicking “open in browser”. Mine opened a browser window to http://127.0.0.1:8123/
I added this to configuration.yaml
# Enable VSCode debugging
debugpy:
start: true
wait: true
And added this to launch.json
{
// Example of attaching to local debug server
"name": "Python: Attach Local",
"type": "python",
"request": "attach",
"port": 5678,
…
I’ve copied the following from my notes so it might be a bit incomplete but this should help you, I’ve also replaced the HA references to the version I’m currently using.
Put this in configuration.yaml and restart Home Assistant
debugpy:
start: true
wait: false
port: 5678
Download and unzip the HA source code from Github for the same version as you are running
In my case I downloaded and unzipped this (I actually cloned it)
In the …/core-2021.6.6/.vscode directory replace the cont…
jmcollin
(Jean-Marc COLLIN)
January 27, 2023, 11:28pm
2
Hello,
Any help for this. I have change many things like removing the Ludeeus Blueprint without more success.
jmcollin
(Jean-Marc COLLIN)
February 2, 2023, 12:47pm
3
Really no idea ? Nobody got the breakpoints working when developing a new Integration ?
I can’t believe that
tmenguy
(Tmenguy)
March 9, 2024, 6:24pm
4
Hi Jean Marc,
I’m struggling too … did you found anything?
jmcollin
(Jean-Marc COLLIN)
March 10, 2024, 11:12am
5
Hello, yes it works now. This is a too old issue, I can’t remember what I do.
tmenguy
(Tmenguy)
March 10, 2024, 11:01pm
6
ah ah you are lucky Not working for me working on a custom component (the netatmo one), and no debug is really a pain, logging has its merit but well nothing beats a breakpoint !
Hi @jmcollin . I would also appreciate being able to use debugging in my development. Would you be able to please share your docker configuration file and/or anything else which might point the rest of us in the right direction?
Thanks in advanced.
jmcollin
(Jean-Marc COLLIN)
March 27, 2024, 10:52am
8
What I propose to you is to have a look on my project which is able to add breakpoint now without problem: GitHub - jmcollin78/versatile_thermostat: A full featured Thermostat for Home Assistant: presets, window, motion, presence and overpowering management
You can have a look at the devcontainer.json which install some addon, the .vscode directory can also be interesting.
Disclaimer: I’m not a Python dev specialist so be fair with python tooling and coding.