openHAB VS Code Extension 0.3.0

Tags: #<Tag:0x00007f1825f6b140>

(Mark) #21

I’ve kinda lost track of the status of the issue with URI mapping when using samba shares. Does this work in the most recent build (#1088)?

(Kuba Wolanin) #22

I didn’t update my setup to #1088 yet so can’t really tell from experience.
There’s this bug raised by @Udo_Hartmann - he’s experiencing it on #1088 so I’m assuming it’s still relevant.

(SteveW) #23

I’m using
OH2 build #1088,
VSCode 1.18.1
VSCode OH2 extension 0.3.0
on a Windows10 x64 machine,
with Openhab2 running on Ubuntu1604
and the /conf mapped via samba share,
and accessed in VSCode over //path-to-server/conf

Upon launching VSCode I get the same error as @Dries did in list post of 19/11/17 against #1084.

I’m new to the extension so not confident which bit is not working though -
in VSCode, code snippets works, autocompletion of existing Item names works, sitemap (Basic) preview works, but it doesn’t spot any syntax errors that are otherwise reported in openhab.log when I save e.g. a new Rule.

(Mark) #24

Thanks. I completely missed that issue. Looks like there’s already a PR in the pipeline… :+1:

(Sebastian) #25

What do I have to do to get this? I am a little bit lost.
Do I need Visual Studio?

(Dries) #26

No, Visual Studio Code (

(marcolino) #27

I’m using:
OH2 2.2.1, with misc-lsp
VSCode 1.18.1
VSCode OH2 extension 0.3.0
on a Windows7 x64 machine,
with Openhab2 running on Debian 9
and the /conf mapped via samba share,
and accessed in VSCode over //path-to-server/conf

I have a couple of questions:

  1. Object explorer does not work. If I click to refresh i got this error:
command 'openhab.command.refreshEntry' not found
  1. If I use wrong syntax, in example
if 1=!2 then

else {

There is no error, so i cannot understand if I misstype something in my code.

Can you help me?


(Jens W.) #28

Just wanted to post a quick “me too”.

I’m on a MacBook & Raspberry running VS Code (latest) with VS Code Plugin (0.3.0) and openhab (build #1094). I’m getting those “on hover” (etc.) errors in VS Code as well:

[Error - 17:26:14] Request textDocument/hover failed.
  Message: Internal error, please look at the server's logs.
  Code: -32603 

In openhab I’m getting:

2017-11-24 17:26:08.050 [INFO ] [el.lsp.internal.MappingUriExtensions] - Path mapping could not be done for 'file:///Users/jens/openHAB/openHAB-conf', leaving it untouched

for every start of VS Code and I’m getting:

2017-11-24 17:26:09.552 [WARN ] [eclipse.lsp4j.jsonrpc.RemoteEndpoint] - Notification threw an exception: {
  "jsonrpc": "2.0",
  "method": "textDocument/didOpen",
  "params": {
    "textDocument": {
      "uri": "file:///Users/<MY_MAC_USER_NAME>/openHAB/openHAB-conf/rules/<MY_RULE_FILE>.rules",
      "languageId": "openhab",
      "version": 1,
      "text": <SOME_CODE>
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at$null$0( ~[102:org.eclipse.lsp4j.jsonrpc:0.2.1.v20170706-0855]
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	... 11 more
Caused by: java.lang.NullPointerException
	at$null$0( ~[?:?]
	... 11 more

for every file open action. I’m also getting:

2017-11-24 19:44:35.648 [ERROR] [eclipse.lsp4j.jsonrpc.RemoteEndpoint] - Internal error: java.lang.NullPointerException
java.util.concurrent.CompletionException: java.lang.NullPointerException
	at java.util.concurrent.CompletableFuture.encodeThrowable( [?:?]
	at java.util.concurrent.CompletableFuture.completeThrowable( [?:?]
	at java.util.concurrent.CompletableFuture.uniApply( [?:?]
	at java.util.concurrent.CompletableFuture$UniApply.tryFire( [?:?]
	at java.util.concurrent.CompletableFuture$ [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker( [?:?]
	at java.util.concurrent.ThreadPoolExecutor$ [?:?]
	at [?:?]
Caused by: java.lang.NullPointerException
	at org.eclipse.xtext.ide.server.WorkspaceManager.getProjectManager( ~[?:?]
	at org.eclipse.xtext.ide.server.WorkspaceManager.doRead( ~[?:?]
	at org.eclipse.xtext.ide.server.LanguageServerImpl.lambda$hover$23( ~[?:?]
	at org.eclipse.xtext.ide.server.concurrent.RequestManager.lambda$runRead$2( ~[?:?]
	at java.util.concurrent.CompletableFuture.uniApply( ~[?:?]
	... 5 more

for every “hover” action.

My VS Code config:

    "": "openhabianpi",
    "openhab.port": 8080,
    "openhab.useRestApi": true,
    "openhab.lspEnabled": true,
    "openhab.restCompletions": false

Item stats and things are shown in VS Code, so the connection works in principle.

Interestingly, the openHab addon “openhab-misc-lsp” has disappeared from Paper UI after updating to one of the most recent #1080/1090-ish builds. The other misc packages seem to be all still there. But I’m guessing this was done on purpose. The logs say that the language server is indeed started.

I’m also getting the

2017-11-24 17:27:20.514 [WARN ] [] - EventAdmin: Blacklisting ServiceReference [{org.osgi.service.event.EventHandler,}={event.topics=smarthome,,,, service.bundleid=109, service.scope=bundle} | Bundle(org.eclipse.smarthome.core_0.9.0.201711202142 [109])] due to timeout!

warning upon start of openhab as well, btw.

Just to be sure I tried again with an SD card image of a freshly installed openhabian installation that I did in September 2017 (then latest unstable, some bindings installed via Paper UI, but otherwise not tampered with) and updated to #1094 right away. And that timeout-error appeared.

(Kuba Wolanin) #29

@jewesta and others experiencing the issues with REST connection and whatnot.
I would appreciate if you shared your exact steps to reproduce this bug + described the environment you’re running VSCode (and openHAB) in.

Here’s the GitHub issue. My comment contains packaged VSIX extension with a potential fix. If the fix works for you, please also comment it in the issue.

That’s because LSP has become already a core, built-in feature of openHAB distro. There’s no need to install it as an extension since distro #1083. Here’s the PR introducing that change.

Thank you all for testing!
I hope we’ll find a good, working solution soon :slight_smile:

Meanwhile, @sjka is working on solving this defect.


(Mark) #30

FYI I logged a couple issues related to vscode and LSP. Using build 1098 and the most recent 0.3.0 code you posted towards the bottom of this issue

First issue is here

And another one here

(The Squid) #31

Just curious if the "Internal error: java.lang.reflect.InvocationTargetException has been addressed.

I also have this appear in the Karaf console

Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Keep-Alive
Exception in thread "TCP Refresh Service" Exception in thread "upnp-async-6277" java.lang.OutOfMemor
yError: Java heap space
Exception in thread "upnp-async-6280" java.lang.OutOfMemoryError: Java heap space
        at java.util.concurrent.ThreadPoolExecutor.addWorker(
Exception in thread "upnp-main-1" Exception in thread "SocketListener(JmDNS-IP-1)" Exception in thre
ad "upnp-async-6264" Exception in thread "upnp-main-2"  at java.util.concurrent.ThreadPoolExecutor.p
        at java.util.concurrent.ThreadPoolExecutor.runWorker(
        at java.util.concurrent.ThreadPoolExecutor$
java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
        at java.util.Arrays.copyOf(
        at java.lang.AbstractStringBuilder.ensureCapacityInternal(
        at java.lang.AbstractStringBuilder.append(
        at java.lang.StringBuilder.append(
        at java.lang.StringBuilder.append(
        at org.jupnp.model.message.UpnpHeaders.addParsedValue(
        at org.jupnp.model.message.UpnpHeaders.parseHeaders(
        at org.jupnp.model.message.UpnpHeaders.getAsArray(
        at org.jupnp.model.message.UpnpHeaders.getFirstHeader(
        at org.jupnp.model.message.discovery.IncomingSearchRequest.getMX(
        at org.jupnp.protocol.async.ReceivingSearch.waitBeforeExecution(
        at java.util.concurrent.ThreadPoolExecutor.runWorker(
        at java.util.concurrent.ThreadPoolExecutor$

I’m running OH 2.3 and the latest version of the VS plugin.

When I encounter that error it kills all of my TCP binding calls that I use to control my lighting.


CalDav Rule For Notification
(The Squid) #32

Anyone have a suggestion?



(Jerome) #33

No sorry.
I have already seen your post and would have already answered if I had an idea.

(Kuba Wolanin) #34

I don’t think this error is caused by VSCode extension whatsoever.
All the work for syntax validation is done by Eclipse SmartHome, and specifically by Language Server. You can search Language Server Protocol to learn more about the subject.

Here’s a list of currently open issues with LSP.

The extension is just a client for the LSP.