VSCode extension issues

And did you try to reset the karaf setting too like shown in the gif?

Yes. I’ve now reset the new setting, that now seems to have done the trick !?

Probably some cached data from one of the beta versions.
Config handling in code is pretty confusing sometimes and has caused several problems over the time…

Info only: I meant to try out new extension on OH2-Windows-localhost combination, but never found the needed round-to-it.
Unexpectedly for me, it force-fed me 1.0 anyway, auto updated.

Some whinges about config json as expected, easily corrected as it suggested. I was prepared for that, but it may come as surprise to some users.
No Auth stuff used in OH2 setting.

All working well - thankyou!

Observation - the extension readme displayed in VSC still talks OH 2.x, omits OH3

I had the issue with the extension showing me an error about depreciated configuration too:

However this is not configured anywhere:
image

image

image

I also searched in the settings.json and could not find the setting.
Reloading the window (as shown in the GIF) didn’t help either.


Strangely enough I was able to fix it by just adding the new property to the settings.json:
"openhab.connection.basicAuth.username": "" and the extension did not complain anymore

Same what happened to me. @Confectrician I think that’s still a bug (and unrelated to caching as I had this issue across many restarts)

Maybe you have some settings in:

\openHAB-conf\.vscode\settings.json

on openHab server and not in VSCode itself.

I looked there too but it wasn’t defined there either. What about you @mstormi

same

This thread seems to be a small mystery linked to extension 1.0

Guessing the “fix” would be more to do with LSP and Quantity types.

Seems to be an LSP problem which is another topic than this one.

Topic related:
I can only guess what’s happening and it seems that my guesses were not 100% accurate so far.
So we need to extend the logging, and check what the extension is doing exactly.

If possible you may provide me a settings config, so i can build up your exact settings.
Message or github email adress should be feasable.

Please try the following extension @mstormi and @Felix_Schneider

Download link: openhab-1.0.0-pr-262-10bd8f8.vsix

It will add some more logging to the Developer Tools (because i don’t want to make a messy output. No one reads all of that.)

Can be viewed with the following steps:

Open Developer Tools
image

Go to Console and apply openhab filter:

Look for following log message types and expand the config info with the little arrow:

This will show what vscode knows about the “deprecated” setting and i am able to see where the warning is coming from.
The output may be different from this simple example, depending on the way your configuration is set up.

for testing purposes I defined "openhab.username": "test123", in c:/Users/.../AppData/Roaming/Code/User/settings.json. The output looks like this:


Are these the values you were looking for?

The values are fine, but i would need some real world examples, when the bug is occurring.
Then we would have to track down which setting is causing the warning to appear.

Do you get an error again when you delete the “workaround” you described above?

Second question:
Extension is reporting deprecated password parameter too.
Did you add that too for testing or is it the bug?

Hello everybody.
I am far from your knowledge in your discussions but have a simple question. In version 1.0.0, “openhab.connection.host” is mandatory, so what do you do when you have several openHAB
servers? Do I have to change the host name in settings.json when I change server to configure?
Have searched in the Community and in the documentation but not found the answer.

That’s not a simple question at all.
As I understand it this setting defines the server that VSC connects to via a) API (to retrieve things,items etc) and b) LSP (to validate code).
@Confectrician: correct ?

Now I myself have been wondering what’s happening when I open multiple files on different OH servers. As probably most OH users I’m using Samba to share /etc/openhab/rules of the OH box.
But my Windoze VSC box does not know that they happen to be on different network drives i.e. different servers. To VSC it’s just another file with a different name.
So when my LSP server is set to A but the file I edit is on server B, how does the LSP validator in A know about the rest of the file and OH instance ?
Or - same question phrased the other way round - how does VSC know it should query B for LSP ?
Would I need to setup a workspace for this purpose and change the workspace’s openhab.connection.host connection to B ?

I still keep getting a bunch of Java error messages at times such as that one below.
Validation suddenly stops working then.
Couldn’t pinpoint yet when exactly it’s happening but my guess is this is related.

openHAB vscode extension has been activated

[Error - 13:49:54] Request textDocument/definition failed.

  Message: Internal error.

  Code: -32603 

java.util.concurrent.CompletionException: java.lang.ClassCastException: class org.eclipse.xtext.common.types.access.TypeResource cannot be cast to class org.eclipse.xtext.resource.XtextResource (org.eclipse.xtext.common.types.access.TypeResource is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @16f6caa; org.eclipse.xtext.resource.XtextResource is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @16e41bb)

    at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source)

    at java.base/java.util.concurrent.CompletableFuture.completeThrowable(Unknown Source)

    at java.base/java.util.concurrent.CompletableFuture$UniAccept.tryFire(Unknown Source)

    at java.base/java.util.concurrent.CompletableFuture.postComplete(Unknown Source)

    at java.base/java.util.concurrent.CompletableFuture.completeExceptionally(Unknown Source)

    at org.eclipse.xtext.ide.server.concurrent.AbstractRequest.logAndCompleteExceptionally(AbstractRequest.java:73)

    at org.eclipse.xtext.ide.server.concurrent.ReadRequest.lambda$doRun$0(ReadRequest.java:69)

    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)

    at java.base/java.util.concurrent.FutureTask.run(Unknown Source)

    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

    at java.base/java.lang.Thread.run(Unknown Source)

Caused by: java.lang.ClassCastException: class org.eclipse.xtext.common.types.access.TypeResource cannot be cast to class org.eclipse.xtext.resource.XtextResource (org.eclipse.xtext.common.types.access.TypeResource is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @16f6caa; org.eclipse.xtext.resource.XtextResource is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @16e41bb)

    at org.eclipse.xtext.ide.server.WorkspaceManager.doRead(WorkspaceManager.java:436)

    at org.eclipse.xtext.ide.server.findReferences.WorkspaceResourceAccess.readOnly(WorkspaceResourceAccess.java:36)

    at org.eclipse.xtext.ide.server.symbol.DocumentSymbolService.doRead(DocumentSymbolService.java:332)

    at org.eclipse.xtext.ide.server.symbol.DocumentSymbolService.getDefinitions(DocumentSymbolService.java:112)

    at org.eclipse.xtext.ide.server.symbol.DocumentSymbolService.getDefinitions(DocumentSymbolService.java:99)

    at org.eclipse.xtext.ide.server.LanguageServerImpl.lambda$definition$24(LanguageServerImpl.java:608)

    at org.eclipse.xtext.ide.server.WorkspaceManager.doRead(WorkspaceManager.java:438)

    at org.eclipse.xtext.ide.server.LanguageServerImpl.definition(LanguageServerImpl.java:607)

    at org.eclipse.xtext.ide.server.LanguageServerImpl.definition(LanguageServerImpl.java:595)

    at org.eclipse.xtext.ide.server.LanguageServerImpl.lambda$definition$23(LanguageServerImpl.java:586)

    at org.eclipse.xtext.ide.server.concurrent.ReadRequest.lambda$doRun$0(ReadRequest.java:66)

    ... 5 more

[Error - 17:26:31] Request textDocument/definition failed.

  Message: Internal error.

  Code: -32603 

java.util.concurrent.CompletionException: java.lang.ClassCastException: class org.eclipse.xtext.common.types.access.TypeResource cannot be cast to class org.eclipse.xtext.resource.XtextResource (org.eclipse.xtext.common.types.access.TypeResource is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @16f6caa; org.eclipse.xtext.resource.XtextResource is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @16e41bb)

    at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source)

    at java.base/java.util.concurrent.CompletableFuture.completeThrowable(Unknown Source)

    at java.base/java.util.concurrent.CompletableFuture$UniAccept.tryFire(Unknown Source)

    at java.base/java.util.concurrent.CompletableFuture.postComplete(Unknown Source)

    at java.base/java.util.concurrent.CompletableFuture.completeExceptionally(Unknown Source)

    at org.eclipse.xtext.ide.server.concurrent.AbstractRequest.logAndCompleteExceptionally(AbstractRequest.java:73)

    at org.eclipse.xtext.ide.server.concurrent.ReadRequest.lambda$doRun$0(ReadRequest.java:69)

    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)

    at java.base/java.util.concurrent.FutureTask.run(Unknown Source)

    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

    at java.base/java.lang.Thread.run(Unknown Source)

Caused by: java.lang.ClassCastException: class org.eclipse.xtext.common.types.access.TypeResource cannot be cast to class org.eclipse.xtext.resource.XtextResource (org.eclipse.xtext.common.types.access.TypeResource is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @16f6caa; org.eclipse.xtext.resource.XtextResource is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @16e41bb)

    at org.eclipse.xtext.ide.server.WorkspaceManager.doRead(WorkspaceManager.java:436)

    at org.eclipse.xtext.ide.server.findReferences.WorkspaceResourceAccess.readOnly(WorkspaceResourceAccess.java:36)

    at org.eclipse.xtext.ide.server.symbol.DocumentSymbolService.doRead(DocumentSymbolService.java:332)

    at org.eclipse.xtext.ide.server.symbol.DocumentSymbolService.getDefinitions(DocumentSymbolService.java:112)

    at org.eclipse.xtext.ide.server.symbol.DocumentSymbolService.getDefinitions(DocumentSymbolService.java:99)

    at org.eclipse.xtext.ide.server.LanguageServerImpl.lambda$definition$24(LanguageServerImpl.java:608)

    at org.eclipse.xtext.ide.server.WorkspaceManager.doRead(WorkspaceManager.java:438)

    at org.eclipse.xtext.ide.server.LanguageServerImpl.definition(LanguageServerImpl.java:607)

    at org.eclipse.xtext.ide.server.LanguageServerImpl.definition(LanguageServerImpl.java:595)

    at org.eclipse.xtext.ide.server.LanguageServerImpl.lambda$definition$23(LanguageServerImpl.java:586)

    at org.eclipse.xtext.ide.server.concurrent.ReadRequest.lambda$doRun$0(ReadRequest.java:66)

    ... 5 more

I’m definitely not an expert but a long while back I did some playing around with the extension with the primary purpose to figure out if one could offload the LSP work to a separate openHAB instance from the production openHAB. The reason was at that time (perhaps still?) the LSP can cause a significant load on the openHAB instance and for some users it was adding lots of latency while they were editing files.

And that makes some sense when one realizes the LSP does the same thing that happens when loading a .rules file. So if there is a heavy hit to the CPU when loading the .rules file, there should be a heavy hit when editing that file and as you type the syntax is checked by the LSP.

If I recall correctly it worked pretty well for the syntax checking. However, it will only be aware of the Things, Items, and Sitemaps that exist on the openHAB instance the extension is connected to. So if you have two or more instances of openHAB, it’ll only know about the Items and such on the one the extension is connected to for the LSP.

Keep in mind this is all pretty old information. I suspect the extension has changed a bit since then. But I post it here in case it’s informative or useful.

Currently there is only one host setting, which is used for all connections. (API and LSP when activated in our case).
The whole code is currently based on the assumption that there is one “server” which is running openHAB.

For sure it would be possible to add some more host settings, but that would raise the question:
Where do start with something like this and where do we stop?
I would agree that it probably makes sense to differentiate lsp and api host like described by rich.

But how should we deal with multiple openHAB servers?
openHAB itself has its difficulties with multi server setups.
(Take a look at the several discussions here for redundant setups.)

One suggestion:
If you wont to configure different openHAB servers independent from each other workspace settings could be useful.
You can add a .vscode folder with a settings.json in each openhab configuration folder and just provide the hostname as setting.

Other settings could be done for all folders in the user settings.
vscode will then use the workspace host setting, because it is higher in the hierarchy and fall back to other configured user settings which would then be available for all servers.

You then would just have to open the config folder you currently want to edit and the correct host would be set.
Hopefully this brings some light in the dark.

Besides this:
I am still happy for any input on the deprecated parameter bug, because i am still not able to reproduce it currently.

1 Like

Just did that; actually I used “Add Folder to Workspace” then VSC creates a file called workspace.code-workspace in that directory and in there are settings {} where you can insert your (adapted) settings.json.
When you edit settings (Ctrl- , ) that file actually is edited when you select the workspace tab.
@Magnus give it a try and add 2 workspaces or as @Confectrician said two dirs “.vscode” with a settings.json each