VS Code openHAB Extension!

syntax
ide
vscode
Tags: #<Tag:0x00007f6ce8c710f8> #<Tag:0x00007f6ce8c70ea0> #<Tag:0x00007f6ce8c70c48>

(Jerome) #102

See https://github.com/openhab/openhab-vscode/issues/3 or the answer @kubawolanin has given 10th of July.
Language Server Protokoll will bring this syntax help, but is not finished yet.


(Christoph) #103

I installed the extension in Visual Studio Code (from the marketplace), but I I’m missing some of the shown features (quick suggestion, auto complete etc., e.g. for sendCommand, like shown in your GIFs). Code validation seems not to work either.
I’m running openHAB 2.2.0 Build #1069, Language Server Support is installed. The Rest API gets a connection.
Is there some more configuration to be done in Visual Studio Code?
Thanks for your help!


(Tom) #104
  • Have you got the openHAB Misc / Language Server Support add-on installed?
    (Do this in paper UI).
  • You also need to ensure that the VS settings for openHAB (In VS Code - File/Preferences/Settings and scroll down to the openHAB ones) are configured for your openHAB Host IP address and port.
    (Either the IP address or host name will do)

That should be it.


(Christoph) #105

I did both. And configuration seems to be ok, because I can connect to the REST API.


(Tom) #106

Is this VS Code setting set to ‘true’?

"openhab.useRestApi": true,

I guess it is as it’s the default.

Are you opening your openHAB config files folder to view your files?

\\OPENHABIANPI\openHAB-share\openhab2-conf

Sorry, I can’t help more.


(Christoph) #107

Yes.

Yes. I open my files from a samba share.

As I’m not using openhabian, I override the settings as follows:

{
    "openhab.host": "192.168.188.55",
    "openhab.port": "8080"
}

Thanks for your help! Perhaps @kubawolanin can help out.


(Kuba Wolanin) #108

Hey @Syn

Could you check if there’s anything relevant in your openhab logs?

Please verify if extension’s version is 0.2.0 and you’re running the latest VSCode on your machine.
Is there “openHAB Items” side panel visible on the bottom left hand side?

Also please check if there are any errors in the Output panel in VSCode. (Alt + F12 > Output)
Somtimes reloading VSCode window should help too (Ctrl + Shift + P > type Reload window)

EDIT: Just submitted a ticket on ESH repository - I’ve encountered some issues on the latest distro as well.

Cheers


(SiHui) #109

Thx. I was already wondering why I get some errors (#1070) when trying to open a sitemap:

error


(Christoph) #110

The openhab log doesn’t show any relevant informations.
There is a “openHab Items” side panel.
VSCode Version is Version 1.17.2 (1.17.2); extension is 0.2.0

Right after the start from Visual Studio Code there are two errors (openHAB Server):

[Error - 18:48:44] Connection to server is erroring. Shutting down server.
[Error - 18:48:44] Connection to server is erroring. Shutting down server.

After reloading VSCode window, there is the same errors as after the start:

[Error - 18:55:21] Connection to server is erroring. Shutting down server.
[Error - 18:55:21] Connection to server is erroring. Shutting down server.

(Christoph) #111

Opening a sitemap actually works for me…


(SiHui) #112

Strange … without installing the Language Server Support everything worked fine, now it is completely broken (since upgrading from #1061 to #1070)

Do we need to change the settings? (Don’t think so …):

{
    "openhab.host": "192.168.2.237",
    "openhab.port": "8080",
}

(Christoph) #113

VSCode Output shows an error with your settings (because of the , at the last line):
Property expected (4,1)
But I don’t know if that is an issue.


(SiHui) #114

Already removed it, no change, thx anyway.


(Jens Meyer) #115

Hi,

I am quite new to openHAB, just received my Pi today and installed openhabian.
When using Visual Studio Code the preview of sitemaps works fine.

But when developing rules I receive the error: Error while connecting to OpenHAB REST API
My settings look like this:

{
	"openhab.host": "openhabianpi",
	"openhab.port": "8080"
}

I also tried using the IP Address, the problem remains the same :frowning_face:
Any ideas or any help?

Thanks
Jens


(SiHui) #116

Disregard this problem.
After I realized that it did work fine from my other computer, I reinstalled VSC and the addon from the failing computer and now everything is back up again. No idea what caused this, though.
Sorry for the confusion. :sunglasses:


(Jens Meyer) #117

OK - I found my mistake. Simple restart of VS Code was the solution :roll_eyes:
Note to myself: Do not work late on openHAB after a hard day at work :wink:


(Tom Araya) #118

Hi Christoph,

did you find a solution? I have exactly the same problem :frowning:

Best Budo


(Chewie) #119

Does the code completion (IntelliSense) not work for anything else than listing my own variables? It does not show the members (properties, methods) of any variable when I press Ctrl + Space after the dot (.).


(Christoph) #120

Hi Tom,
no, but I think it will get fixed soon (see the ticket on ESH repository).
Regards
Christoph


(Tom Araya) #121

Great, thanks!