openHAB VS Code Extension 0.3.5

I only use vscode for openhab. If i move the items-files, rules-files and so on from left side (explorer-view) to the workbench, i can open all files in multiple tabs, only if i press the files on left side with the mouse-button (left or middle button) it only opens 1 single tab and every new items-file is opened in the same tab.

latest VSCode 1.18.1 on Win10 64bit Prof

Openhab 2.2 snapshot - latest build # 1138 from 15.12.2017 - running on debian server

openhab.log shows errors like this:

2017-12-15 07:49:22.853 [ERROR] [nrpc.json.ConcurrentMessageProcessor] - java.net.SocketException: Connection reset
java.lang.RuntimeException: java.net.SocketException: Connection reset
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:103) [102:org.eclipse.lsp4j.jsonrpc:0.2.1.v20170706-0855]
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:84) [102:org.eclipse.lsp4j.jsonrpc:0.2.1.v20170706-0855]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
	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: java.net.SocketException: Connection reset
	at java.net.SocketInputStream.read(SocketInputStream.java:210) ~[?:?]
	at java.net.SocketInputStream.read(SocketInputStream.java:141) ~[?:?]
	at java.net.SocketInputStream.read(SocketInputStream.java:224) ~[?:?]
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:61) ~[?:?]
	... 6 more


and


2017-12-15 07:51:06.412 [WARN ] [eclipse.lsp4j.jsonrpc.RemoteEndpoint] - Unmatched cancel notification for request id 1
2017-12-15 07:51:06.768 [WARN ] [eclipse.lsp4j.jsonrpc.RemoteEndpoint] - Unmatched cancel notification for request id 2
2017-12-15 07:51:22.871 [WARN ] [eclipse.lsp4j.jsonrpc.RemoteEndpoint] - Unmatched cancel notification for request id 10
2017-12-15 07:51:33.999 [WARN ] [eclipse.lsp4j.jsonrpc.RemoteEndpoint] - Unmatched cancel notification for request id 14
2017-12-15 07:51:35.651 [WARN ] [eclipse.lsp4j.jsonrpc.RemoteEndpoint] - Unmatched cancel notification for request id 16

My point is that there’s no single line of code in my extension that would affect tabs management.
Thus, I need you to double check it before I go further with investigating that.
Please disable the extension and try reproducing the bug again.

Same behaviour with deactivated extension.

Looks like a duplicate of [lsp] InvocationTargetException and SocketException when closing vscode with LSP enabled · Issue #4629 · eclipse-archived/smarthome · GitHub

So it’s not my extension’s defect. Take a look at VSCode docs and see if it’s something conigurable. If it’s clearly a defect, report it here.

I think this is expected behavior in VSCode.

If opening a file, it will be loaded in a tab. Now, if loading the next file without changing anything, VSCode decides to load the new file in the same tab. But if you change something in the file, the Tab name changes from italics to normal and the tab gets ‘pinned’. Now the tab ins’t overloaded by a new opened file but instead a new tab is opened.

2 Likes

If you want, you can override this behavior by setting this in your vscode system defaults.

    "workbench.editor.enablePreview": false,
3 Likes

@kubawolanin Is there a way (in future releases) that clicking on an item inside of the code editor (i.e. while editing a *.rule file) to see it’s value?
Maybe by letting the item browser window automatically jump the the related entry, by showing a small hint or having it in the context menu somehow?
Right now the item browser is nice, but as there seems to be no search function it is partially very time consuming finding the related item.

@LarsK please submit an issue with your idea - I’ll see what I can do during the holiday break :wink:

Done :smiley:.
And many thanks in advance …

You can also double-click on a file in the explorer, the tab header in italics (or the file name in italics in the “open editors” pane) to “pin” it.

Hello all,

I’m new to OpenHAB so I apology in advance as my knowledge about the platform is very limited although I’ve been reading a lot. Today I just upgraded to latest openhabian release (2.2.0-1) because I wanted to give a try to the integration with Visual Code.
So I installed Visual Code as well, and the extension for OpenHab (release 0.3.5). I also changed the configuration file to point to my openhabian IP server.
As soon as I open Visual code, I receive the message “internal error, please look at the server’s logs”.

And this is where my nightmare starts :wink: This is what I’ve done so far:

  • If I change the parameter openhab.lspEnabled from true to false, the error message disappears
  • Syntax checking seems to work properly
  • Server is listening to port 5007 and it seems it’s connecting with my desktop computer (see attached file)
  • But if I try to check openhabian logs, there is no errors to trace this. Nothing, void

Can someone help me to work it out?

Thank you!!

LSP_log

PD: I’m about to give up cause although I have a minimal installation to get used to this environment (only 2 wifi led controllers), it’s not so uncommon to see some error messages in my var log during the starting process and it’s very time consuming to debug them as openhab is a big, very big project. On the other hand, I’m really engaged as I love this project but it’s taking a huge amount of time to get a grasp.
I would love to be knowledgeable about openHab!!!

I have exactly the same problem. I am using openhab-2.2.0 release and VS Code Extension 0.3.5.

The error messages described in the reply above openHAB VS Code Extension 0.3.5 come from the openhab server (easily to spot using wireshark listening to port 5007).

I am migrating from OpenHAB1 and was hoping to have VS Code check my (existing) rules file for errors, but I am not sure if it will do that even with LSP working? I was expecting an error highlighting similar to the Openhab/Smarthome Designer.

Syntax validation is being handled with Language Server that’s developed within Eclipse SmartHome.

In order to check whether it’s installed properly on your machine:

  1. Log in to your Karaf console (ssh openhab@localhost -p 8101 in your OH host)
  2. Type the following command:
openhab> bundle:list | grep Language
138 │ Active   │  80 │ 0.10.0.201712141004    │ Eclipse SmartHome Language Server

I’m using latest SNAPSHOT (Unstable) build, but it works on 2.2 distribution too.

Please check your openHAB logs and report any issues with Language Server Protocol here.

Yes, I get the expected output:

openhab> bundle:list | grep Language
138 â Active â 80 â 0.10.0.b1 â Eclipse SmartHome Language Server

but there is no output in the openhab.log related to the Language Server, although it is responding (seen via Wireshark).

Can the loglevel be adjusted for the Language Server (how)?

If it would work properly, would VS Code validate the code and mark errors/warnings along with a description of what’s wrong just like the Designer did?

Yes:
image

Thank you. I have created an issue since it still does not work for me and openhab.log is throwing exceptions.

Been migrating from Openhab/Smarthome Designer to VSCode. So far it’s gone pretty well, but I’m left with a few questions after reading this thread and the README on github:

  1. Integrated quick search of openHAB Docs page (Alt + Shift + O)
    Alt + Shift + O does nothing on my system. I have the eclipse keybindings extensions installed, but I have disabled it and restarted, still nothing

  2. Integrated quick search of openHAB Community
    How to open this search?

  3. Code snippets for openHAB, including Design Patterns by Rich Koshak
    Great idea! How do I access these?

  4. Quick Karaf console access
    You guessed it… how do I trigger this? I have configured the ssh command in settings

PS I am more than happy to submit a PR for the README for these

Thanks!
Dave

Hi @dbadia

I would recommend you to check out the VSCode usage docs to answer your basic questions.

You can reconfigure your keybindings to match virtually any command/action in VScode. I suspect that Eclipse keybindings overrode that setting, and that’s ok

  1. Select any text in openHAB files (items/rules/sitemap/persist/script etc)
  2. Ctrl + Shift + P
  3. Type “Community” and choose the right option

These are stored here and in fact are not documented anywhere. If we want them to be in docs, we may need to create a bash script that would generate a table of them in some place in README file. PRs are welcome!

Ctrl + Shift + P > type “Karaf”

Be my guest! :slight_smile:

Hi @kubawolanin,

I’m running OH2.2 on RPI3 and suffer some performance issues while just typing in my code. VS Code seems to check each and every character I’ve typed in and hence creating quite a high load on my RPI3. Can I somehow fix this by myself?

Hey @ptweety,
I’ve been experiencing these issues too and they’ve been reported in ESH repository.