VS Code Extension With openHAB 3

Hi all,

Since questions are being asked repeatedly i wanted to share a quick Thread.
It can be used as a short FAQ when questions come up.
I will add important changes and culprits here when needed.

My Rest API doesn’t work any longer

This should mostly be related to our api security update in openHAB 3.
openHAB 3 introduces an authentication layer to the api.

Basic Auth configuration

You have to configure your openHAB instance proper and add some configuration to the openHAB extension.

on openHAB-Side

Make sure to activate Allow Basic Authentication in the API Security settings.

on VS Code Extension config

Add your user credentials (from your openHAB Admin User) to the extension settings.
The needed settings are:


When your openhab.host and openhab.port settings didn’t change since you installed/upgraded, everything should work again on the api connection.

What about token based authentication? Can i use that?

Yes you can use it with a generated token.
Generate a custom api in the user window of Main UI and copy it in the Username setting for the vscode extension.
Make sure to leave the password setting empty!

"openhab.username": "MY_GENERATED_TOKEN",
"openhab.password": "",

I am using openHAB with https enabled and it still doesn’t work

The code we are using for accessing the api has problems with https. That’s a known problem.
So you would currently have to allow http requests to the api to get it running.



Thank! A! Lot! :blush:

1 Like

Basic UI Rendering in VS Code not longer possible when having configured REST API Access?

Thank you very much for providing some guidelines to activate OpenHAB 3 REST API Access to VS Code. I followed your guide and could gain access to Things and Items via REST API in VS Code.

However, when provisioning openhab.username with the API token, I realized that another functionality broke in VS Code: When I want to render the Basic UI in VS Code, the Basic UI is accessed with the API token as username and empty password - as shown in the output window of VS Code. When I copy this URL, I can successully open the Basic UI in the browser, but VS Code cannot. Is there a way to keep this functionality?

Best regards,

I am facing the same problem. please give some suggestion to us. Thanks in advance.


I didn’t check this so far to be honest.
I will try to evaluate what’s happening.

Anyway i am working on a bigger update to replace the “username workaround” with a proper token based authentication with it’s own configuration parameter.
This should probably solve the problem aside.

1 Like


Is there any chance to work with rules created in OpenHAB WebUI (stored in jsondb)? UI based editor has some ‘IntelliSense’ which is mostly working only for buildin variables. That would be a very nice feature!


Hey @cinadr

Currently there is some work in progress as a “proof of concept” for something similar.

The goal is to access some api parts (so in fact the jsondb in an indirect manner) and transform it to virtual yaml files for editing.
This is of course a limited part for now but may be extended in the future, when we get it running properly.

1 Like

This is really amazing. Eagerly waiting to be able to test this. Thank you.


Hello to all,

I had several issues with Visual Studio but now “Code Completion, Items View, Things View and Sitemap Preview” works on my machine.

My issue was the “settings.json” for the user.

I saw this message and changed to the new one.

Usage of deprecated config => openhab.host <= detected.
Usage of deprecated config => openhab.port <= detected.

But then my code completion does not work.
I have reverted my change and with this “settings.json” it worked for me.

    // latest one but they did not work
    //"openhab.connection.host": "192.168.178.XX",
    //"openhab.connection.port": 8080,
    // deprecated setting but they work
    "openhab.host": "192.168.178.XX",
    "openhab.port": 8080,
    "[openhab]": {
        "editor.defaultFormatter": "openhab.openhab"
   "window.zoomLevel": 0,
    "openhab.karafCommand": "ssh openhab@192.168.178.XX -p 8101 -t 'log:tail'",
    "oh-alignment-tool.enableBetaFeatures": true,
    "openhab.connection.basicAuth.username": "",
    "openhab.languageserver.remoteEnabled": true,
    "openhab.languageserver.remotePort": 5007,
    "openhab.useRestApi": true,
    "openhab.connection.authToken": "oh.VisualStudio1.XXXXXX",

@Confectrician: Could this be possible or maybe my Visuals Studio setup is mixed up?

Hi, is it going to be updated anytime soon? I miss sooooo much function “create items from thing channels” (or some similar name).

The deprecated paramters could be removed anyway in the nearer future.

But currently i am not investing any time into the extension, due to time limitation on my side.
I may have time to do some basic little fixes, like removing the old paramters completely, but will currently not do any refactorings or bigger additions and improvements.

But as said many times already in different places.
This is not a one man show. Everyone is welcome to get some skills and help out.

I have proven many times that i am willling to get some spare time for helping others get into gith/github/coding (the last one limited to my self learned knowledge).
But i have not seen anyone willing to seriously jump in here in the last years.

1 Like

I completely understand you, but I am sorry I am not able to support you with further fixes or development due to missing knowledge in tools development.

If I can help you with providing information or testing something this would be possible.

1 Like

Had the same issue. Turned out I got improper double quotes when copying it from the web. There are three characters, intro and closing quotes and the one from the keyboard.

Hi all. I have created and set an API key. I have also set the host to the right IP, Yet, I am getting this error message:


Is there still anything else I need to enable in openhab besides creating the API key?

Did you set the AuthToken in the VSCode Plugin openHAB section?

Yes that is where I added the key. The config currently looks like this:

    "workbench.colorTheme": "Default Dark+",
    "window.zoomLevel": 1,
    "editor.inlayHints.enabled": "offUnlessPressed",
    "openhab.connection.authToken": "xsbnuYMCUioEOhieVtX8Bjx93TcEhcA7G2JcABQPWLNclhqauhQrMXnwpooTDp1D5MUJcbP0tvlurjNlKUQ",
    "openhab.host": "",
    "openhab.port": "8080"

Mine looks like this:

    "openhab.connection.host": "",
    "openhab.connection.port": 8080,
    "openhab.connection.authToken": "oh.vscode.yFxMaV3vNnQElB1e0qDixxxxxxxxxxxxxxxxxxxxxxFZGvjeY1kVnirB5hg",

But I am not sure if you need .connection..

Nope, that is not the correct Auth Token. Please create a new one and paste it completely to the connection configuration, like this:

    "openhab.connection.host": "",
    "openhab.connection.port": 8080,
    "openhab.connection.authToken": "oh.remote.j3YrEx6xqRSkaBYojlUOCVahINazLxEE3K8oftWB0Hw1239SbCeUkTsIsDtv54F1Ghf0ZQLXmi7V5ZxYq1btQ",
    "openhab.itemCasing": "camel",
    "openhab.languageserver.remoteEnabled": true,
    "openhab.useRestApi": true,
    "openhab.languageserver.remotePort": 5007,
    "openhab.consoleCommand": "$OPENHAB_RUNTIME/bin/shell",
    "editor.codeActionsOnSave": {}

Please keep attention about openhab.connection.host and openhab.connection.port

1 Like