VS Code openHAB Extension!

Take a look at the folder /var/lib/openhab2/etc/

There should be at least 2 files named org.ops4.pax.logging.*, one with ending cfg, another with dpkg in it. just rename the .cfg to .cfg.old and the .dpkg* to .cfg (i.e. replace the old file with the new one)

Hi! I found this when i was searching for syntax highlighting and autotextcompletion. First of all i want to say thanks for that great work! It is already showing my files in the correct color. Unfortunately i have to connect to the folder manually every time. i read the post, where the autoconnect is explained but i can’t get it working. I’m editing from my mac and connecting to my raspberry via smb. in my workspace setting i wrote:

“folders”: [
“path”: “/Volumes/openHAB2-conf”
“settings”: { “settings”: {
“openhab.host”: “openhabianpi.local”,
“openhab.port”: 8080
"openhab.useRestApi": false

one thing i noticed there is that it can only connect when i activated the volume prior. when i change the path to:
it’s not working at all.
what am i doing wrong?
Sitemap previews are not working either.

I never used visual studio before so please excuse my noobish questions. :slight_smile:

Please try


VS Code is NOT Visual Studio! :slight_smile:

1 Like

I think we need a meme for that. :smile:


yeah i know. that was not clearly written from me. i downoaded vs at first but then i recognized and got the right program (after following the OH extension to the store) … i’ll try later, thank you!

Hi there!

It worked - partly :wink:
I am connected now (after i recognized that the quotes can’t be copy/pasted correctly) even after i restart the program.
but i can’t get the rest api working.

my code:

	"folders": [
	"path": "smb://openhabianpi.local/openHAB2-conf"
	"openhab.host": "",
	"openhab.port": 8080,
	"openhab.useRestApi": true,
    "openhab.username": "openhabian",
    "openhab.password": "openhabian"

i tried the ip adress as host as well as openhabianpi.local



1 Like

What does "can’t get rest API working’ mean in detail?

If you just don’t see items and things explorer, the extension simply might be initiated yet.
It does not initiate with the start of VSCode.
You have to open at least one openHAB config file (items/rules/things, doesn’t matter which special type) or make it to the “active tab” by clicking into the editor.
At this time the openHAB extension will init itself and connect to rest API.

If you have another problem occuring some details would be good to give a more precise answer. :slight_smile:

You are right, that was not a good issue description :slight_smile:
I try to see the Sitemap preview and when i click there VSC gives me the following:
Error while connecting to openHAB REST API.
And i don’t see the preview but only white color when i click the openHAB icon.
I can access the sitemap as well as the rest api directly with my browser.

Ok that’s something to work with. :slight_smile:

Are you using “basic auth” for your installation or ar this the credentials for e.g. connecting to openhabain reomtely like you would do with a raspberry pi?

If you aren’t using basic auth or don’t know what i am talking about now
try setting it up this way:

"openhab.username": "",
"openhab.password": ""
1 Like

which password is this? when i connect via terminal to my raspberry i connect to:
ssh pi@raspberrypi.local
then when i want to access the OH console i type:
ssh -p 8101 openhab@localhost
or do you mean another password?

I don’t know which userdata is needed here …

Thank you!

Try it exactly as I posted above with no user and password data.

Those settings are only needed if you have enabled an additional security layer.

not working :frowning:

i am editing the Workspace-Settings, right?
I recognized another settings file in the OH-Config Folder:
.vscode and there settings.json.
but that one is empty.

Same error message?


@Jonas88 please try the extension from this post:

The fix from there is not released yet.
Read the VSCode docs on how to install an extension manually.

thank you! I’ll try it :slight_smile:
now i am getting a new error:
Error while connecting to openHAB REST API. getaddrinfo ENOTFOUND openhabianpi.local openhabianpi.local:8080

How do you enable additional security layer?

Hello! After using the IP adress of my Raspberry instead of openhabian.local as host it worked.

Edit: Not true.
I can now use the preview of my sitemap but i still get the error:
Error while connecting to openHAB REST API. connect ECONNREFUSED

Could you try placing the config in the user settings instead of workspace settings?


Got it working now :slight_smile: Thank you!
Here is my config for Workspace and User: