VS Code openHAB Extension!

I’m using the same settings (here xen4.4.1), for vm 1 CPU, 1GByte RAM, but no problems with “killing the server”. How many bindings/rules/items do you use?

~400 rules
~1100 items
14 bindings

that’s quite a bit… I don’t coming near this, so, we have to ask others if they observe problems…

I’ve recently started using this, but I don’t have full syntax checking. Also clicking on preview gives Error command’openhab.basicUI’not found

I’m running an APT-GET installed Snapshot build 1216

My user settings are:

{"openhab.host": "xxx.xxx.xxx.xxx",
 "openhab.port": 8080,
 "openhab.useRestApi": true,
 "openhab.username": "",
 "openhab.password": ""

xxx.xxx.xxx.xxx is the ipAddress of my OpenHAB machine

In Workspace settings is the folder path to my OpenHAB machine, and an empty field called “settings”
Folder Settings are empty.

To get it working I just added the server address and left the rest as defaults, only adding the extra when it didn’t work.

What am I missing?

You shouldn’t need to add anything manually. Just right-click on the gear wheel in the left lower corner and chose settings. You get at least 2 lists, left side is standard settings, this one is sorted by categories, so scroll down to openHAB Configuration. To change settings, just click at the pen in the line and chose change settings, this will copy the line immediately to the right side.
Be aware that there are user settings and workspace settings. I don’t know which one will overrule the other.
For full syntax checking you will need at least

 "openhab.host": "xxx.xxx.xxx.xxx"
 "openhab.port": 8080
 "openhab.useRestApi": true
 "openhab.lspEnabled": true
 "openhab.lspPort": 5007

And it’s a good idea to set

 "openhab.restCompletions": true

either for getting code completions. I’m not sure it you have to enable the RestApi for syntax checking, but you definitely have to for code completions.


@kubawolanin just set up SSH to connect to openHAB with private key and use the tail for the log. i also set up sftp to automattically transfer files. I will post my solution here maybe you think it could be helpfull to be added to the github readme. Or have some ideas to improve the Setting up proccess to make it easier?

  1. Setting up logging without exposing system to the public, and keeps working after upgrade. One time setup. openhab-cli command had some Problems but a good solution could be found.

1.1 PC used to edeit code with VSCode, generate key, this is necessary to avoid typing in the password every time.


1.2 Copy content of public key id_XXXXX.pub to Openhab Server

// Linux
ssh-copy-id -i ~/.ssh/mykey user@host
// Windows
scp "<PathToFile>/id_XXXXX.pub" pi@<Ip-of-openHAB-Server>:~/.ssh/authorized_keys
// manually 
// copy content of `id_XXXXX.pub` to   
// existing or created file `/.ssh/authorized_keys`

1.3 Change shh config on server

sudo nano /etc/ssh/sshd_config
PubkeyAuthentication yes
AuthorizedKeysFile  .ssh/authorized_keys .ssh/authorized_keys2

1.4 Set Karaf command in VSCode, press ctrl+comma and add at the left left side

// I am not a fan of this, needs extra configuration, is not persistent when updating, and opens system to public
"openhab.karafCommand": "ssh username@%openhabhost% -p 8101 -t 'log:tail'",
// Don't do this there are too much drawbags
"openhab.karafCommand": "ssh username@%openhabhost% openhab-cli console -p habopen `'log:tail'`",
// do this, one drawback it is not colored. 
"openhab.karafCommand": "ssh username@%openhabhost% tail -q -f /var/log/openhab2/events.log -f /var/log/openhab2/openhab.log",

Drawbacks solution two

  1. Do not append 'log:tail' there seems a bug which will prevent the log from beeing continously written. Do we have to type something again. No password but log:tail.
  2. A second bug seems to be ansi color codes which i did not get to work propperly yet. The escape sequence for Ansi codes get stripped of when piped to the terminal console from the ssh session. But the Code part will persist and clutter the Output.
  3. Karaf console default timeout is set to 30 minutes, so it has to be reopened often or the default settings have to be changed.
  4. It is a ssh connection in a ssh connection.

Restart VSCode, openhab extension seems to have a missing feature which reads in configuration when they are changed it only loads new/changed configs when restarted.

1.5 Try to run Karaf ctrl+shift+p type openh select openHAB: Open Karaf Console.
1.6 Wait for the connection and the tailing log.

The best thing is you have access to the console changing debug levels retrieve infos etc, imho very ussefull. You can use the terminal like an ssh session.

Additional information i use windows 10 build in openSSH.

  1. Add folder /etc/openhab2 as sftp to automatically transfer files when you save from/to Server to/from pc wich edits the files.

2.1 install SFTP extension, restart VSCode
2.2 Open a folder which is destined to be your new openhab content folder. Menu File/Open Folder
2.3 Configure it SFTP, press ctrl+shift+p type sftp choose SFTP: config
My basic setting looks as follows, have a look at the project page for more details

    "protocol": "sftp",
    "host": "<IP>",
    "username": "<Username e.g pi>",
    "password": "<password e.g raspberry>",
    "context": "<path to your local openHAB files e.g D:/CODE/OpenHAB_FILES>",
    "remotePath": "<path to remote openHAB files e.g /etc/openhab2/>",
    "uploadOnSave": true

2.3 Fetch remote files, press ctrl+shift+p type sftp choose SFTP: Download
all your remote files should be in your local folder now.
2.4 Edit a file and watch the log go crazy! :wink:

@kubawolanin edited the logging now it works very nice. This is now a very neat working environment, do you think this could be part of the readme?


Did all that, restarted Visual Studio Code and still opening the sitemap and clicking on the top right openhab icon gives me

Error command ‘openhab.basicUI’ not found

Is there any way of checking that it can access Rest and anything else that it needs? I can see a bunch of JSON formatted text in a web browser if I type in


Does that mean rest is OK?

1 Like

If it look similar to this, yes:

Which version of the Extension are you using?

Yes it looks similar albeit with worse formatting which is likely down to browser version. I’m using version 0.3.5

That’s a chrome extension i am using. :slight_smile:

Strange. is working for me.

DId you test other commands like “show in paperUI” in the file/item view.
command not found sounds not like a extension error message.
maybe you should uninstall and reinstall the binding again for testing purpose.

I’m not sure where that is, do I just open up an items file and then click on the top right openhab item? If I do that I get the basicUI not found error.
If I click on “OPENHAB ITEMS” at bottom left below the list if items and rules files I get a refresh icon and clicking on that gives “command’openhab.command.refreshEntry’ not found”
Same thing happens with “OPENHAB THINGS” which is below it

Than there definetely something went wrong with your installation.
Please do a fresh install and give us feedback here.

You mean uninstall visual studio code and also the extension, is there any documentation I should follow to ensure a valid set of feedback?

I would start with only uninstalling the extension and reinstalling it again.
If you haven’t yet configured much and startet with code only for openhab a complete reinstall is valid too of course.

No there is no cos about valid feedback.
That was just my formal way to say - “Tell us if it worked” :smiley:

@kevin at the left are the standart settings.
At “1” you can type openhab and then only the openhab related settings will be displayed.
At “2” are the user settings, i have only this three.
At “3” are the workspace settings, these are empty in my case. Make sure you don’t have concurrent settings.

Also you have to have basicUI enabled in your configuration! Just saying.

I have my config folder listed in picture 1 item 3, and if I delete it I get presented with “you have not yet added a folder to the workspace,” “Add Folder” button which I then click and the entry reappears.
I do have BasicUI Installed as well as Rest UI, PaperUI, Habmin and Habpanel.

My Workspace settings

"settings": {},
"folders": [
		"path": "V:\\openhab2\\etc\\openhab2"

I just changed Picture 1 item 2 to match yours albeit with my servers ip address and nothing has changed. Essentially I am editing at a file level with autocomplete for the currently open file only

Interestingly I just clicked on RestAPi from my openhab opening menu and was presented with this message

{"schemaValidationMessages":[{"level":"error","message":"Can't read from file http://xxx.xxx.xxx.xxx/rest/swagger.json"}]}

which may be a clue

How is your setup? openHAB server (RPI, PC windows/linux) editing computer?

Maybe there is a problem with file permission or a firewall is blocking the access.

OpenHAB is on its own Debian 64Bit PC with UFW turned OFF. Desktop is Windows 10 64Bit, all on the same LAN. Do you see anything on your setup If you put http://yourOpenHABipAddress:5007 into a web browser?

1 Like

No i can’t.

Maybe just uninstall VSCode and extension and try it with the lates version?

Also how are the file permissions of your files in /etc/openhab2 on your Debain PC.

No that seems to be a problem with the corresponding rest ui.
I have it too and it doesn’t affect my vscode behavior.

As i already said:
It is strange that vscode doesn’t even find the commands,
so i think there is a problem even befor the extension can do anything wrong.

Fresh install would be the best.