Visual Studio Code - howto: connect to Rest API?

I’ve just encountered it myself and will try to fix it in the following days.
Cheers

1 Like

Hmm I’ve added some additional error output to the message popover and I get the error regarding REST connection to the host param from User Settings, and not from Workspace settings.
There might be some issue with retrieving the configuration parameters from /.vscode/settings.json file stored in our openhab-config folders or higher.

I’m still not sure how to resolve this. Seting everything in user settings looks like a workaround (which works in my case) but it’s not an option for the multi-workspace environments…

I’ve submitted an issue: https://github.com/openhab/openhab-vscode/issues/67
Please provide as much details there as possible. Your OS, OH version, where is it stored etc.

EDIT: Please also take a look at the VSCode backlog of issues with respect to the workspace/user settings. There are quite a few of them and they might be related to our issues too.

Thanks

2 Likes

I am trying to get this working too and can’t. My problem is that openhab is only reachable over https.
https://192.168.2.xxx:8444/rest/things is working and returning some text. So I added

"openhab.host": "https://192.168.2.xxx",
"openhab.port": 8444

But it can’t connect. Any idea how to get this working?

PS openhab is running on a raspberry pi in the network and VS code on a windows pc if thats important (config files are shared via samba)

Small update: as advised to me here I installed another version of the addon and now I get a slightly different warning which says that I am using a self signed certificate. This is right as I am using the one generated by Openhab. There should be a settings to allow this :wink:

Hi All,

I also struggled with the Rest API connection. It was possible or get a connection to an openHAB server running on a Synology NAS, but I couldn’t connect to a local openHAB server running on Windows7. What helped me was to disable => reload => enable => reload in the openHAB VS code extension dialog:
grafik
After doing so, I suddenly could connect also to the local openHAB server running on Windodws.

Hope this helps someone.

5 Likes

Wow, it helped me as well. Great!

For me, just restarting VS Code made the REST connection work.
However, you must right-click on the conf folder and select “Open with Code”.

Hidden Folder: .vscode
File: settings.json

{
    "openhab.host": "192.168.1.xxx",
    "openhab.port": 8080
}

image
…assuming you have Samba setup:

1 Like

Error while connecting to openHAB REST API. Invalid protocol: 

Have the same problem!
I tested everything, but nothing worked.
Does somebody has any idea?

Can you provide some more date?

Which version of code?
Which version of the extension?
Did you open the conf folder direct from the network or did you add a drive to your explorer?

Maybe you could also list what “everything” means in detail.

The more information, the better the chance of finding the problem. :slightly_smiling_face:

1 Like

Sorry that I did not name any details… :confused:

VSC Version : 1.30.1
Extension Version: 0.4.1

I mount the conf folder as a drive to my explorer.


as configuration i used this:
(For USER CONFIG and Workspace-Config)

“openhab.host”: “http://xxx.xxx.xxx.xxx”,
“openhab.port”: “8080”,
“openhab.useRestApi”: true,
“window.zoomLevel”: 1,
“workbench.colorTheme”: “Liqube Dark Code”,
“workbench.iconTheme”: “vscode-great-icons”,
“workbench.panel.location”: “bottom”

But nothing worked, so I used all the configurations that were shown here, but didn’t work

Could you try to remove the http:// in openhab.host ?
I think there was a filter in the extension which recognized if there was an http set, but i am not sure.

1 Like

On windows 10, it did not work for me, but I’ve just installed deepin and configured everything there from new …

It worked

But i must thank you because i use openhab.host instant of http:// and it works.

1 Like

Just for the record…

I just started VSC, setup the right directory for my files and put the following into settings.json (accessible from Settings in VSC and search for openhab.

{

    "openhab.host": "192.168.xxx.x"

}