VS Code openHAB Extension!

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

GitHub - openhab/openhab-vscode: VS Code extension for openHAB configuration files

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:

openHAB2 code snippets

Integrated search engine:

openHAB2 code snippets

Intelligent sitemap preview:

openHAB2 code snippets

Installation

This extension is available on the Visual Studio Marketplace → openHAB - Visual Studio Marketplace

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
Beginner Question: items isnt correct
Autowarm (CLOSED)
CLI vs GUI
(SOLVED) ESP8266 with Json by wifi
Xiaomi mihome rules not working
[Solved] Openhab 2.1 does not know my sitemap
VS Code Extension for newly introduced yaml config?
Command '0' not supported by type 'OnOffValue'
Cron based rule with Rule On/Off switch and Telegram reporting fails
[SOLVED] Switch multiple timer in succession
[SOLVED] Calculating windchill
[SOLVED] Switch case error
Setting up office light timers with time of day
[SOLVED] Sitemaps and Items not detected
[SOLVED] Help with a rule
Trigger a puschbutton of a VMBGPOD (velbus)
[SOLVED] Ultimate guide to debugging rules?
Designer with PaperUI
Help with another simple rule (SOLVED)
How to install Smarthome Designer on Windows
Anyone up for a challenge? Nuuubeee here
OH2: Which interface allows me to do what I could in OH1
[SOLVED] ExecuteCommandLine & OH2.2
[SOLVED] Openhab linking items, create a sitemap and run script when doorbell is pushed
Debugging New Rules
Linking a string and integer together to create a string for notifications
Update to openhab 2.3 kinda broke everything
MAP transform in rule not working
Rule stopped working
The correct way to verify the config (configuration check)
Möhlenhoff Alpha BUS - Solution
[SOLVED] WIFI LED - Wakeup Event - Brightness variable help [HSV Format]
"mismatched character expecting '\n' " error when adding comment to .items file
Rules - An error occurred during the script execution: null
[SOLVED] Multiple Things in a Single File - Can this be done?
Editing rules... best option for editor
Alexa controlled wol and exec shutdown

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