VS Code openHAB Extension!

Tags: #<Tag:0x00007f61739fb470> #<Tag:0x00007f61739fb358> #<Tag:0x00007f61739fb1f0>

Samba is configured as root, All Rules files have full access by root, and OH runs as root as I have too many things that are fiddly to get working when it doesn’t.
Maybe I should put OpenHABian on a spare Pi and see if that works?

:face_with_raised_eyebrow:
Sorry, don’t want to be harsh, but that sounds like a transcription for “I’m too lazy to care about security.”
I’m not aware that this could cause problems with VSCode, but just to ensure… Maybe you could setup another instance of openHAB(ian) on another Computer without root permission.

I’m pretty sure when you are able to access the files via samba (read/write), VSCode should work like a charme. I’m using VSCode since openHAB plugin 0.1, and I never encountered severe problems. Auto completion and code correction did emerge after ~ OH2.2 nightly #1035, but if using OH2.2 stable or OH2.3 nightly, this should definitely work (and does for me, VSCode 1.21, openHAB plugin 0.3.5 vs. OH2.3.0 Build #1225).

I can read and write files via Samba and edit these without issue, and without error checking with VSCode, so I don’t think that is the problem. When I click on OPENHAB ITEMS or OPENHAB THINGS or try and open a Sitemap is when the errors start. Surely if it spits a “can’t find basicUI” error it means the path to it is wrong?

I do care about security, but I gave up on getting it to work without root in the past as it broke too many things in the V1.x on a GPIO equipped Pi days. I’m happy to ditch the root access if needs be and its possible to do so without breaking large parts of my system, which apart from this editor issue works very well.
I have an RFXCOM device, Z Stick, exec binding running Python, Node and shell scripts to name a few things off the top of my head that need to keep working.

By adding the user openhab to the respective groups i could allways solve access rights and get everything running.

Mostly its user rights, forgotten shebang, libraries in wrong folder, wrong path or somthing like this.

I don’t say the solutions are obvious but mostly they can be found. My way to get meaningfull error prompts is to always try to execute the command as usr openhab in a shell. This ensures that i can see the error prompt and that i have a bash. Whish is disabled for the openhab user.

sudo -u openhab <do something>

How to just enable sudo for a single command and some related information about openhab and sudo is explained here.

To enable troubleshooting of this I have just downloaded OpenHabian V1.4, copied it onto a memory card, stuck it in a Pi3 and let it run. I then selected “Standard Package” before changing VSCode over to use the OpenHabian instance. I added the network location to VSCode and then created default.items. default.site.map with a single item in each before saving and then pressing the openhab icon in the top right of VSCode. The error is it still can’t find BasicUI. Hopefully this takes out all variables on my Ubuntu system as we are now trying to get it working with a Pi running OpenHabian.

VSCode User settings

{
"openhab.host": "192.168.1.10",
} 

VSCode Workspace Settings - it populated this itself once I browsed to the workspace on OpenHabian

{
"settings": {},
"folders": [
	{
		"path": "\\\\192.168.1.10\\openHAB-conf"
	}
   ]
}

default.items

Switch test

default.sitemap

sitemap default label="Main Menu"	{
    Frame label="test" {
        Switch item=test
    }
}

This setup displays correctly in a web browser, so hopefully we can troubleshoot this easily.
Right now I have a fresh install of VSCode and a fresh install of the addon

The errors are:
Can’t preview sitemap - command’openhab.basicui’not found
Clicking OPENHAB.ITEMS - command ‘openhab.command.refreshEntry’ not found
Clicking OPENHAB.THINGS - command ‘openhab.command.refreshEntry’ not found

Turning off Windows Firewall temporarily doesn’t make any difference.

To my untrained eye it seems that the Commands in the Extension are missing because the errors all read command “command that failed” not found

Thats what i already said 20h ago and 1d ago.

But i have never heard of problems like this before.
From what you told here, you have installed the extension directly through the extension marketplace in the extension tab.

You could try to uninstall and install from a .vsix file.
You can find the current releases here: https://github.com/openhab/openhab-vscode/releases

Jerome,
The .vsix file did it once I worked out it wouldn’t install from a folder on the desktop. If works on both my Debian System and also the test copy of OpenHabian I just loaded
Thanks very very much for your help!

I wonder if others will have problems loading the extension from the VSCode Marketplace

1 Like

Maybe it is a bad combination of your environment and/or firewall which breaks the download?!
I have no detailed idea about it currently.

I am doing the install through marketplace since we have that ability and it always worked.

But anyway, fine to hear that it works for you now.

2 Likes

Absolutely! i highly encourage anyone to edit the README.md file and contribute to the project as well :slight_smile:
I have currently very limited time for any OH-related work, sadly, but the great thing about open source is that anyone can make it better :slight_smile:
Big thanks to @Confectrician for taking his time and effort to maintain the repository these days!

Cheers

Unfortunately my spare time is limited too last days/weeks.
I have not the time i would like to invest currently, especially to finish the localization for example.

@Josar:

Just open an issue or PR in the vscode repo and we will improve the readme.
Maybe interesting to keep in mind (cc @kubawolanin here) :


But we can of course split that up afterwards.

1 Like

Since getting this to work yesterday I’ve noticed OpenHAB.log get many errors in it, is this a bug or do I likely have further hoops to jump through?

. Normal editing of values in a rules file gives:

2018-03-15 09:31:55.632 [WARN ] [eclipse.lsp4j.jsonrpc.RemoteEndpoint] - Unmatched cancel notification for request id 8
2018-03-15 09:31:56.105 [WARN ] [eclipse.lsp4j.jsonrpc.RemoteEndpoint] - Unmatched cancel notification for request id 10

and using auto complete by typing “val” unleashes many lines of rubbish in openhab.log, although it does give a list of possible values, so maybe it works

2018-03-15 09:30:58.661 [ERROR] [eclipse.lsp4j.jsonrpc.RemoteEndpoint] - Internal error: com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: org/objectweb/asm/ClassReader
java.util.concurrent.CompletionException: com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: org/objectweb/asm/ClassReader
at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:273) [?:?]
at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:280) [?:?]
at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:604) [?:?]
at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:577) [?:?]
at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:442) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
at java.lang.Thread.run(Thread.java:748) [?:?]
Caused by: com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: org/objectweb/asm/ClassReader
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2201) ~[?:?]
at com.google.common.cache.LocalCache.get(LocalCache.java:3937) ~[?:?]
at com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4739) ~[?:?]
at org.eclipse.xtext.xbase.ide.types.ClasspathScanner.getDescriptors(ClasspathScanner.java:85) ~[?:?]
at org.eclipse.xtext.xbase.ide.types.ClasspathScanner.lambda$getBootClasspathDescriptors$2(ClasspathScanner.java:99) ~[?:?]
at org.eclipse.xtext.xbase.lib.internal.FunctionDelegate.apply(FunctionDelegate.java:42) ~[?:?]
at com.google.common.collect.Iterators$8.transform(Iterators.java:799) ~[?:?]
at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48) ~[?:?]
at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48) ~[?:?]
at com.google.common.collect.Iterators$5.hasNext(Iterators.java:548) ~[?:?]
at com.google.common.collect.Iterators$5.hasNext(Iterators.java:547) ~[?:?]
at org.eclipse.xtext.xbase.ide.contentassist.ClasspathBasedIdeTypesProposalProvider.createTypeProposals(ClasspathBasedIdeTypesProposalProvider.java:77) ~[?:?]
at org.eclipse.xtext.xbase.ide.contentassist.XbaseIdeContentProposalProvider.completeJavaTypes(XbaseIdeContentProposalProvider.java:411) ~[?:?]
at org.eclipse.xtext.xbase.ide.contentassist.XbaseIdeContentProposalProvider.completeJavaTypes(XbaseIdeContentProposalProvider.java:407) ~[?:?]
at org.eclipse.xtext.xbase.ide.contentassist.XbaseIdeContentProposalProvider._createProposals(XbaseIdeContentProposalProvider.java:204) ~[?:?]
at org.eclipse.xtext.xbase.ide.contentassist.XbaseIdeContentProposalProvider.createProposals(XbaseIdeContentProposalProvider.java:641) ~[?:?]
at org.eclipse.xtext.ide.editor.contentassist.IdeContentProposalProvider.createProposals(IdeContentProposalProvider.java:94) ~[?:?]
at org.eclipse.xtext.ide.server.contentassist.ContentAssistService.createProposals(ContentAssistService.java:108) ~[?:?]
at org.eclipse.xtext.ide.server.contentassist.ContentAssistService.createCompletionList(ContentAssistService.java:73) ~[?:?]
at org.eclipse.xtext.ide.server.LanguageServerImpl.lambda$completion$14(LanguageServerImpl.java:425) ~[?:?]
at org.eclipse.xtext.ide.server.WorkspaceManager.doRead(WorkspaceManager.java:234) ~[?:?]
at org.eclipse.xtext.ide.server.LanguageServerImpl.completion(LanguageServerImpl.java:427) ~[?:?]
at org.eclipse.xtext.ide.server.LanguageServerImpl.lambda$completion$13(LanguageServerImpl.java:406) ~[?:?]
at org.eclipse.xtext.ide.server.concurrent.RequestManager.lambda$runRead$2(RequestManager.java:116) ~[?:?]
at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:602) ~[?:?]
... 5 more
Caused by: java.lang.NoClassDefFoundError: org/objectweb/asm/ClassReader
at org.eclipse.xtext.xbase.ide.types.ClasspathTypeDescriptor.forJarEntry(ClasspathTypeDescriptor.java:150) ~[?:?]
at org.eclipse.xtext.xbase.ide.types.ClasspathScanner.loadJarDescriptors(ClasspathScanner.java:229) ~[?:?]
at org.eclipse.xtext.xbase.ide.types.ClasspathScanner.loadDescriptors(ClasspathScanner.java:154) ~[?:?]
at org.eclipse.xtext.xbase.ide.types.ClasspathScanner.lambda$getDescriptors$1(ClasspathScanner.java:83) ~[?:?]
at com.google.common.cache.LocalCache$LocalManualCache$1.load(LocalCache.java:4742) ~[?:?]
at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3527) ~[?:?]
at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2319) ~[?:?]
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2282) ~[?:?]
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2197) ~[?:?]
at com.google.common.cache.LocalCache.get(LocalCache.java:3937) ~[?:?]
at com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4739) ~[?:?]
at org.eclipse.xtext.xbase.ide.types.ClasspathScanner.getDescriptors(ClasspathScanner.java:85) ~[?:?]
at org.eclipse.xtext.xbase.ide.types.ClasspathScanner.lambda$getBootClasspathDescriptors$2(ClasspathScanner.java:99) ~[?:?]
at org.eclipse.xtext.xbase.lib.internal.FunctionDelegate.apply(FunctionDelegate.java:42) ~[?:?]
at com.google.common.collect.Iterators$8.transform(Iterators.java:799) ~[?:?]
at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48) ~[?:?]
at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48) ~[?:?]
at com.google.common.collect.Iterators$5.hasNext(Iterators.java:548) ~[?:?]
at com.google.common.collect.Iterators$5.hasNext(Iterators.java:547) ~[?:?]
at org.eclipse.xtext.xbase.ide.contentassist.ClasspathBasedIdeTypesProposalProvider.createTypeProposals(ClasspathBasedIdeTypesProposalProvider.java:77) ~[?:?]
at org.eclipse.xtext.xbase.ide.contentassist.XbaseIdeContentProposalProvider.completeJavaTypes(XbaseIdeContentProposalProvider.java:411) ~[?:?]
at org.eclipse.xtext.xbase.ide.contentassist.XbaseIdeContentProposalProvider.completeJavaTypes(XbaseIdeContentProposalProvider.java:407) ~[?:?]
at org.eclipse.xtext.xbase.ide.contentassist.XbaseIdeContentProposalProvider._createProposals(XbaseIdeContentProposalProvider.java:204) ~[?:?]
at org.eclipse.xtext.xbase.ide.contentassist.XbaseIdeContentProposalProvider.createProposals(XbaseIdeContentProposalProvider.java:641) ~[?:?]
at org.eclipse.xtext.ide.editor.contentassist.IdeContentProposalProvider.createProposals(IdeContentProposalProvider.java:94) ~[?:?]
at org.eclipse.xtext.ide.server.contentassist.ContentAssistService.createProposals(ContentAssistService.java:108) ~[?:?]
at org.eclipse.xtext.ide.server.contentassist.ContentAssistService.createCompletionList(ContentAssistService.java:73) ~[?:?]
at org.eclipse.xtext.ide.server.LanguageServerImpl.lambda$completion$14(LanguageServerImpl.java:425) ~[?:?]
at org.eclipse.xtext.ide.server.WorkspaceManager.doRead(WorkspaceManager.java:234) ~[?:?]
at org.eclipse.xtext.ide.server.LanguageServerImpl.completion(LanguageServerImpl.java:427) ~[?:?]
at org.eclipse.xtext.ide.server.LanguageServerImpl.lambda$completion$13(LanguageServerImpl.java:406) ~[?:?]
at org.eclipse.xtext.ide.server.concurrent.RequestManager.lambda$runRead$2(RequestManager.java:116) ~[?:?]
at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:602) ~[?:?]
... 5 more
Caused by: java.lang.ClassNotFoundException: org.objectweb.asm.ClassReader cannot be found by org.eclipse.xtext.xbase.ide_2.12.0.v20170519-0752
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:461) ~[?:?]
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:372) ~[?:?]
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:364) ~[?:?]
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:161) ~[?:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:?]
at org.eclipse.xtext.xbase.ide.types.ClasspathTypeDescriptor.forJarEntry(ClasspathTypeDescriptor.java:150) ~[?:?]
at org.eclipse.xtext.xbase.ide.types.ClasspathScanner.loadJarDescriptors(ClasspathScanner.java:229) ~[?:?]
at org.eclipse.xtext.xbase.ide.types.ClasspathScanner.loadDescriptors(ClasspathScanner.java:154) ~[?:?]
at org.eclipse.xtext.xbase.ide.types.ClasspathScanner.lambda$getDescriptors$1(ClasspathScanner.java:83) ~[?:?]
at com.google.common.cache.LocalCache$LocalManualCache$1.load(LocalCache.java:4742) ~[?:?]
at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3527) ~[?:?]
at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2319) ~[?:?]
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2282) ~[?:?]
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2197) ~[?:?]
at com.google.common.cache.LocalCache.get(LocalCache.java:3937) ~[?:?]
at com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4739) ~[?:?]
at org.eclipse.xtext.xbase.ide.types.ClasspathScanner.getDescriptors(ClasspathScanner.java:85) ~[?:?]
at org.eclipse.xtext.xbase.ide.types.ClasspathScanner.lambda$getBootClasspathDescriptors$2(ClasspathScanner.java:99) ~[?:?]
at org.eclipse.xtext.xbase.lib.internal.FunctionDelegate.apply(FunctionDelegate.java:42) ~[?:?]
at com.google.common.collect.Iterators$8.transform(Iterators.java:799) ~[?:?]
at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48) ~[?:?]
at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48) ~[?:?]
at com.google.common.collect.Iterators$5.hasNext(Iterators.java:548) ~[?:?]
at com.google.common.collect.Iterators$5.hasNext(Iterators.java:547) ~[?:?]
at org.eclipse.xtext.xbase.ide.contentassist.ClasspathBasedIdeTypesProposalProvider.createTypeProposals(ClasspathBasedIdeTypesProposalProvider.java:77) ~[?:?]
at org.eclipse.xtext.xbase.ide.contentassist.XbaseIdeContentProposalProvider.completeJavaTypes(XbaseIdeContentProposalProvider.java:411) ~[?:?]
at org.eclipse.xtext.xbase.ide.contentassist.XbaseIdeContentProposalProvider.completeJavaTypes(XbaseIdeContentProposalProvider.java:407) ~[?:?]
at org.eclipse.xtext.xbase.ide.contentassist.XbaseIdeContentProposalProvider._createProposals(XbaseIdeContentProposalProvider.java:204) ~[?:?]
at org.eclipse.xtext.xbase.ide.contentassist.XbaseIdeContentProposalProvider.createProposals(XbaseIdeContentProposalProvider.java:641) ~[?:?]
at org.eclipse.xtext.ide.editor.contentassist.IdeContentProposalProvider.createProposals(IdeContentProposalProvider.java:94) ~[?:?]
at org.eclipse.xtext.ide.server.contentassist.ContentAssistService.createProposals(ContentAssistService.java:108) ~[?:?]
at org.eclipse.xtext.ide.server.contentassist.ContentAssistService.createCompletionList(ContentAssistService.java:73) ~[?:?]
at org.eclipse.xtext.ide.server.LanguageServerImpl.lambda$completion$14(LanguageServerImpl.java:425) ~[?:?]
at org.eclipse.xtext.ide.server.WorkspaceManager.doRead(WorkspaceManager.java:234) ~[?:?]
at org.eclipse.xtext.ide.server.LanguageServerImpl.completion(LanguageServerImpl.java:427) ~[?:?]
at org.eclipse.xtext.ide.server.LanguageServerImpl.lambda$completion$13(LanguageServerImpl.java:406) ~[?:?]
at org.eclipse.xtext.ide.server.concurrent.RequestManager.lambda$runRead$2(RequestManager.java:116) ~[?:?]
at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:602) ~[?:?]
... 5 more

together with this at the bottom of the VSCode Window

[Error - 09:30:58] Request textDocument/completion failed.
Message: Internal error, please look at the server's logs.
Code: -32603

Setting “openhab.lspEnabled”: false, seems to turn off the errors and auto complete

Dumb question…

Trying to hit the Karaf console from VSCode, but it’s telling me:

ssh : The term 'ssh' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Tried instaling Putty and making an environment variable (I am on Windows) titled “ssh”, but that didn’t seem to do the trick…

@picarsqu3 Are you on Windows 10?
I use openSSH build in windows.

https://blogs.msdn.microsoft.com/powershell/2017/12/15/using-the-openssh-beta-in-windows-10-fall-creators-update-and-windows-server-1709

If not maybe this helps.

1 Like

Hi,

VS Code seems to send a request to openHAB REST API every time a new character is entered into the editor. Syntax checks slows down to unusable. I’m running openhabianpi. Am I missing any configuration settings to make it faster?

Cheers
Arno

@pernozzoli it’s not a REST call, but a JSON RPC-based communication of LSP (Language Server Protocol) for syntax validation with your OH.
You can disable it with "openhab.lspEnabled": true (hit Ctrl + , for settings) but ultimately I’d look through the log files and see if there are any stack traces regarding lsp.

Cheers,
Kuba

Thx, would be great, I’m seeing

this too (RPi 3, openHAB snapshot #1268)

The MSDN URL worked for me, thank you!

My VSCode autocompletion / error checking is slow as hell as well. It rhymes, but its a pain.
For non-believers I have created a very short video in terrible quality (to reduce upload size and protect my precious “privacy”). Never mind the stuff I entered, its nonsense anyway, but what you can see is how painfully slow autosuggest works. The red “error” marker builds up letter by letter until it finally has “read” the entire word and then shows the autosuggest dropdown. Error handling thus is also painfully slow. openhab.log looks unsuspicious.
The upload will be available for 30 days / thus mid June.

Same for me, the red error marker is creaping character by character…

I just realized there is not even an issue for it, so I opened one: