VS Code openHAB Extension!

I’m pleased to announce that openHAB has now an official Visual Studio Code extension. :trumpet: :trumpet: :trumpet:

https://github.com/openhab/openhab-vscode

Features

  • Code snippets for openHAB including Design Patterns by @rlkoshak
  • Syntax highlighting for openHAB DSL (rules, items, scripts and sitemaps).
  • Integrated quick search of openHAB docs page (Alt + Shift + O)
  • Integrated Basic UI preview window (Ctrl + Alt + O or editor title icon)

Screenshots

openHAB2 code snippets:

Integrated search engine:

Intelligent sitemap preview:

Installation

This extension is available on the Visual Studio Marketplace -> https://marketplace.visualstudio.com/items?itemName=openhab.openhab

You can also install it manually:

  1. Download openhab-0.1.0.vsix from this release page on your hard drive
  2. Open command line in the same folder you downloaded the extension
  3. Type the following command:
code --install-extension openhab-0.1.0.vsix
  1. Open Visual Studio Code
  2. Open openhab configuration (openHAB-conf) folder
  3. Enjoy! :wink:

Further development

There are a number of ideas that we’d like to implement in the extension (like incorporating LSP for better Xtend syntax validation).
I truly believe this will become a solid alternative for Eclipse SmartHome Designer.
In the meantime we’ll be working with @Kai to publish the extension in the VS Marketplace, so you won’t need to install it manually.

57 Likes

This is really great. I like especially the idea of using the LSP. Would be great to have a language server implementation of the sitemap and rule syntax. This could then be uses for VS.Code, brower-based editors and Java-based tooling.

Wow, so much better then ESHD! I love it!!!

1 Like

Cool, I will try that one out as soon as possible. Looks really promising.

Thanks, Kuba! Totally awesomesauce! <3

the first questions arise. :slight_smile:
How does the preview work? Do I need to have some services running or is it just parsing the sitemap and has the default styles applied internally? Currently it shows nothing for my sitemaps (or a newly created one).

See this section in README although I admit it’s not written in most clear way possible :slight_smile:

You need to have openHAB running in order to preview changes. The sitemap is the actual http://YOUROPENHABHOST:8080/basic/… running from your server.

Generally, it assumes that you access your openHAB config files from either:

  • Samba share (e.g. \\OPENHABIANPI\openHAB-conf\)
  • Local folder (e.g. c:\openhab\configuration) - didn’t test it on Unix based machines, though. Windows only :open_mouth:

There might be a bug in a place that checks the hostname based on file path. I’ll take a look at it later today. EDIT: Already resolved

Cheers!
Glad you guys like it :slight_smile: More stuff is about to come.

1 Like

I thought so, but was hoping that maybe the sitemap is just parsed with the help of static/internal openHAB stylesheets or scripts (just UI and non-functional). So basically it is just a browser window within vsCode. :slight_smile:

Respect

ditto !

Fantastic work!!!

I’ve already made a PR to make it work under macOS.
Should be no problem to make it work under *NIX, albeit the mounting scheme is not the same on every distro.

Friggin Awesome!!! :clap:

Beste News today. :smiley:
This looks awesome.

Great Work.

Will this eventually support quick suggestions in code?

Have to say I like it more than Eclipse already. Great work.

Technically this should be possible.

Thank you - the branding “IntelliSense” was escaping me. Having code completion would be great.

@KidSquid @Confectrician It’s certainly possible! There’s an issue in the pipeline to utilize LSP for Xtend language. This way we would get all the goodness that’s seen in ESHD - code formatting, quick suggesting, validation and so on.
Prerequisite of that feature is to upgrade Xtend to a newer version.

@dennisausbremen Thank you for the PR! I’ll take a look at it today. :slight_smile:

So its more a question of “when” it is possible and not “if” it is possible. .)