VS Code openHAB Extension!

syntax
ide
vscode
Tags: #<Tag:0x00007fd30f6c5568> #<Tag:0x00007fd30f6c53d8> #<Tag:0x00007fd30f6c5298>

(Jerome) #223

I would start with only uninstalling the extension and reinstalling it again.
If you haven’t yet configured much and startet with code only for openhab a complete reinstall is valid too of course.

Feedback:
No there is no cos about valid feedback.
That was just my formal way to say - “Tell us if it worked” :smiley:


(Josar) #224

@kevin at the left are the standart settings.
At “1” you can type openhab and then only the openhab related settings will be displayed.
At “2” are the user settings, i have only this three.
At “3” are the workspace settings, these are empty in my case. Make sure you don’t have concurrent settings.

Also you have to have basicUI enabled in your configuration! Just saying.


(kevin) #225

I have my config folder listed in picture 1 item 3, and if I delete it I get presented with “you have not yet added a folder to the workspace,” “Add Folder” button which I then click and the entry reappears.
I do have BasicUI Installed as well as Rest UI, PaperUI, Habmin and Habpanel.

My Workspace settings

{
"settings": {},
"folders": [
	{
		"path": "V:\\openhab2\\etc\\openhab2"
	}
  ]
}

I just changed Picture 1 item 2 to match yours albeit with my servers ip address and nothing has changed. Essentially I am editing at a file level with autocomplete for the currently open file only

Interestingly I just clicked on RestAPi from my openhab opening menu and was presented with this message

{"schemaValidationMessages":[{"level":"error","message":"Can't read from file http://xxx.xxx.xxx.xxx/rest/swagger.json"}]}

which may be a clue


(Josar) #226

How is your setup? openHAB server (RPI, PC windows/linux) editing computer?

Maybe there is a problem with file permission or a firewall is blocking the access.


(kevin) #227

OpenHAB is on its own Debian 64Bit PC with UFW turned OFF. Desktop is Windows 10 64Bit, all on the same LAN. Do you see anything on your setup If you put http://yourOpenHABipAddress:5007 into a web browser?


(Josar) #228

No i can’t.

Maybe just uninstall VSCode and extension and try it with the lates version?

Also how are the file permissions of your files in /etc/openhab2 on your Debain PC.


(Jerome) #229

No that seems to be a problem with the corresponding rest ui.
I have it too and it doesn’t affect my vscode behavior.

As i already said:
It is strange that vscode doesn’t even find the commands,
so i think there is a problem even befor the extension can do anything wrong.

Fresh install would be the best.


(kevin) #230

I uninstalled VSC from control panel, then reinstalled. The Openhab extension was still there so I uninstalled that and then reinstalled from the extensions box. openHAB code version is 0.3.5 and VSC is version 1.21.0 as it was before and nothing has changed, the program still can’t find basicUI when I click on the Openhab icon at top right with the sitemap open.
Perhaps its easier to go back to using Designer until a few more have this problem? I like the new look and it seems a lot more stable than Designer, but having to debug using errors in the logs when rule files are loaded seems a backwards step.


(kevin) #231

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?


(Udo Hartmann) #232

: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).


(kevin) #233

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.


(Josar) #234

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.


(kevin) #235

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


(Jerome) #236

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


(kevin) #237

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


(Jerome) #238

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.


(Kuba Wolanin) #239

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


(Jerome) #240

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.


(kevin) #241

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


(c) #242

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…