Need Help with Debugging OpenHAB Binding using Visual Studio Code

Hello everyone,

I’m currently developing a new binding for OpenHAB and I’m having some trouble with debugging my code. My current process is to write my code, package it into a JAR file, place it in the addon folder, and then run OpenHAB. However, I’m finding that I can’t effectively debug my code this way and it´s time consuming.

I use Visual Studio Code as my preferred development environment. Is there a way I can set up debugging in this environment? I’ve heard that remote debugging is an option, but I’m unsure how to set this up in VS Code. Any help or guidance would be greatly appreciated.

In addition, I would like to know if there are any best practices or recommended workflows for debugging OpenHAB bindings. I’m quite new to OpenHAB development, so any advice would be really helpful.

Thank you in advance for your support!

Best regards, Rush Almosa

Did you see the documentation about vscode: Visual Studio Code | openHAB

1 Like

Hello Hilbrand,

Thank you for your response. I have indeed seen the documentation for Visual Studio Code on the openHAB site. It has been somewhat helpful, but I was hoping for a way to fully debug my code, including setting breakpoints, tracking variables, and so forth.

Thank you once again for your help.

Best regards, Rush Almosa

Exactly that is possible when following the mentioned documentation. After following the prerequisites, pressing F5 in VS Code will copy the jar to the addon folder and attach a debugger to it, so you can set breakpoints from within VS Code.

1 Like

Hello Danny,

Thank you so much for your clarification. I realize now that I wasn’t starting the process correctly with F5, which was causing my issue. Now that I’ve done that, it’s working as expected and I can debug with breakpoints within VS Code.

I really appreciate your help with this. It’s made a significant difference to my development process.

Best regards, Rush Almosa