VS Code - openHAB-Extension: No code completion active

My setup is:

openHAB 2.3.0-1 (Release Build) - openhabian on raspberry pi 3

Seems like my network share with folder openHAB-conf is ok.

grafik

All my openHAB files appear in VS Code (Latest Version) installed on Win10.

grafik

From my point of view, everything that is necessary for code completion should be there.
But there is no code completion active. I expected something like shown in openhab-demo.gif.

As @rlkoshak mentions in his post, there should be a code completion with <ctrl><space>.
When I type in rule + <ctrl><space> like shown in openhab-demo.gif, I get a message ā€˜loadingā€™, but then nothing happens.
grafik

Looks like openHAB-Extension isnā€™t active.

I read the documentaiton and searched the forum, but couldnā€™t find a solution. Or maybe I did not understand it?

What can be wrong within my installation? Thanks for any hint!

Did you set the openhab.host property?

Didnā€™t change any setting by myself. Should I?
All settings are default from openhabian-installation.

See the instructions https://github.com/openhab/openhab-vscode/blob/master/README.md#configuration

Iā€™ve read this page before and compared the settings.

Instruction say:

openhab.host (mandatory), default: openhabianpi
openhab.port (optional), default: 8080

Instruction also say: These settings should work fine on Windows machines and openHAB installations using the recommended openHABian setup.

Thatā€™s why I think my settings are correct. Am I wrong?

can you open http://openhabianpi:8080 ? If so then those settings are sufficient. If not then the host needs to be set to the IP address of your openhab instance.

Thatā€™s strange. I tried and could not open http://openhabianpi:8080.
That surprised me because I know it worked so far.

Thatā€™s why I stopped openhab.service and started it again.

While openhab was starting, I could open http://openhabianpi:8080 and openHAB-Extension was active for a few minutes!
grafik

After openhab was fully started (which took at least >30 minutes) I couldnā€™t open http://openhabianpi:8080 anymore and openHAB-Extension wasnā€™t active anymore.

I tried that again and realized, that when openhab.service is stopped and I type in rule + <ctrl><space> a error appears.
grafik

But when I close that error (click on x) the code completion appears.

And when I start openhab.service again, http://openhabianpi:8080 and openHAB-Extension are not working anymore. Once while starting I got this error:
grafik

BTW: Always when VS Code is running, my openhab rules are executed very, very slow. This is a known issue/bug. To me, it looks like my problem could be related to this.

Edit: At the moment, openhab.service is running and I can open http://openhabianpi:8080. But openHAB-Extension is still not working. Strange!

While trying different user settings I switched openhab.useRestApi from default true to false and now code completion and Items treeview are functional !!!
grafik

grafik

I do not understand that, because of the comment in settings.json file.
It says with setting false Items tree view and code completions are not possible.
grafik

Is that a bug? Are the values reversed?

But no matter. Hopefully it stays that way.
@rlkoshak Thank you very much for your help!

Iā€™m not sure what is going on but am glad you got it working. Iā€™ll keep my eye open for other reports of this odd behavior and open an issue if I see it reported elsewhere.

1 Like

Same behaviour on my Win7 system: neither code completion nor Items/Things treeview have been active with standard installation of VS Code/openHAB Extension/openhabian (raspi 3).
After setting openhab.useRestApi to false code completion works. Items/Things treeview now shows now ā€œThere is no data provider registered that can provide view data.ā€ instead of being empty.

De-/activating and re-installing openHAB Extension has no effect.

Windows 7 Home Premium SP1, openHAB 2.4.0 Release Build, VS Code 1.30.1 (user setup), Extension openHAB 0.4.1.

Anyone any idea how to show entries in Items/Things treeview?

Turn on openhab.useRestApi again.
Items and Things are grabbed through restApi so they cannot be shown, when you turn it off in the config.

if you are facing performance problems with code completion, when Rest API is enabled you can try to set openhab.restCompletions to false instead.

Thanks, now everything works fine.
The main mistake was to define "openhab.host": "192.168.178.40:8080" Omitting the port leads to a perfect world :wink:

Thatā€™s true, since the port is available to a separate setting. :slight_smile:

THANK YOU - THANK YOU - THANK YOU!!! Iā€™ve had the vscode installed for months and always ignored the error about unable to connect to the serverā€¦ and all this time Iā€™ve been wondering why the vscode extension is so uselessā€¦ lol. I didnā€™t get code completion until Iā€™ve fixed this.