Unable to show Things in VS Code with Openhab 3

Hello =)

Yesterday my new Synology DS920+ arrived on which I installed OH 3 in a Docker container.
Everythings working fine, i transferred all my things, items etc. from OH 2.5.2, needed some adjustmest but now everythings listed and reachable in OH3 GUI.

But…
I just cant to get Visual Studio Code running. I edited the json.xml (which I also edited to use the prior 2.5.2. which worked).
I changed the openhab.host and openhab.port (as its not running on 8080 as the old installation) and the OpenHAB plugin does list all Items correctly.
But in the “things” tab theres only the blue slider moving from left to right and I’m getting the error message “Error while connecting to openHAB REST API”.

How can there be a difference between Things and Items where Items work via REST, things not?

Misc: I tried to get all things and items in the OH 3 GUI Developer REST API tool. There i get all things and items.

If you need any further information, be free to ask.

Thanks for your help!

Are you able to reach the things api endpoint in your installation manually (e.g. with the rest apit documentation UI installed)?

Yes i am. Via the rest api from the GUI - Developer Tools, i can get all things and items.
Also i can control all items via rest (using my Streamdeck e.g.)

Also as stated, vs code oh plugin does list my items correctly, and updates them when i change sth in the .items.
But no things.

That’s also what makes me wonder a bit.

If it is working in general, the problem could be located in your installation.
But i have no real idea how to debug this now.

I don’t know if this is what you’re running into, but the OH3 things endpoint now requires authentication. I’m not sure if VS Code is set up to do that yet.

I’m not sure exactly when this changed in the API, nor what version of OH3 you’re running.

I installed a new docker image of 3.0.0M5, imported my files, same behaviour.
Items are displayed in vs code, things are not and stillt the error message.

Do you know if there’s a way to get a more detailed error message from vs code? The “error while conecting to openhab rest api” does not say much… :slight_smile:

Well thats true, if i set a rest call in m, browser, items getting shown, things not. For things theres an auth error.

I also tried setting my vs code oh extension settings and provided username and pw of my oh instance. But didnt work either.

For this you would have to enable basic auth in the rest api.
This can be configured in the new main ui.

Basic auth should be supported so far and work with the username and password setztings in the extension.
But we definetely have to add native auth support in the extension in the nearer future.

2 Likes

Wow, well I think i have missed the “Allow Basic Auth” setting in the gui.
As soon as I activated it, set username and password in vs Code, restarted vsc, the Things gets loaded.

Im not that pleased that i have to enter my password in clear text in the settings.json, but it would work that way. have to think about it :wink:

But thank you very much!

1 Like

My preferred solution would be to add token based auth in the extension too.
You could then store one token over there.

1 Like

If theres a tutorial how to get the token and where to place the token, that would be awesome! Maybe someone who develops the vs code extension reads this thread =)

That should be me. :wink:

1 Like

Well, good to know und Hut ab, the extension is already awesome.
I disabled the LSP “feature” as i always get tons of errors in the openhab.log and vs code output while editing rule. But otherwise its superb :wink:

The one you are looking for already answered… (@Confectrician)

Regarding API Token, just press your admin login in MainUI. On the signout page you see the option to create tokens…