VS Code openHAB Extension!

OK thanks for the explanation.

OK thanks for the explanation.

This is an awesome tool. Thanks for creating it.

Running it on a Mac, and only ran into one issue so far (which actually is not a Mac issue). If openHAB is running on a port other than the default 8080, the sitemap display doesn’t work because the port number is hardcoded to 8080. Is this something that could be made configurable in the future?

Thanks!

Absolutely! @dennisausbremen is making some awesome progress with configurability and macOS support, see: Added functionality to open openHAB Preview on macOS based systems by dennisausbremen · Pull Request #14 · openhab/openhab-vscode · GitHub

Port is indeed hardcoded here. I didn’t realize you can serve OH on port other than 8080. :slight_smile:

Thank you guys for an amazing feedback!

Thanks! Guess I need to put this repo on my watch list. :slight_smile:

Concerning configuration, it would be really cool to have multiple configs for people with several OH instances. It would be nice to be able to select a config and have it load the hostname and port, as well as the path for the config directory. For example, I have 4 OH instances (dev, test, and 2 prod instances). The dev instance is the Eclipse IDE on a Windows box, the test instance runs on an Ubuntu box with a non-default port (something else is on 8080), and the 2 prod instances run on headless industrial PCs located in racks. All the configs are Samba shares to the Windows box.

1 Like

This would be definitely possible thanks to VS Code Workspace settings.
Once you open folder in vs code and save it as a workspace, you’ll be able to store all kinds of settings in /<yourworkspace>/.vscode/settings.json file. Its content would look like this:

{
    "[openhab]": {
        "hostname": "192.168.0.2",
        "port": 9090
    }
}

But that requires @dennisausbremen’s implementation first :slight_smile:

1 Like

@mhilbush: Since my PR is merged now, you just have to wait for @kubawolanin to make a new release and you’re good to go.

1 Like

I’m planning to release 0.0.2 later today.

I’m also wondering if you’d like to see a feature of a quick openHAB documentation search within VSCode, just like we do with Basic UI. Interested?

  • Keep Docs search in a separate browser window
  • New “quick Docs search” tab within VSCode
0 voters

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

Great!!! Thanks for the good work on this :slight_smile:

1 Like

Respect… that’s totally awesome… Looking forward to see further progress :slight_smile:

Where to change the Default path to the OpenHab service running? I’m accessing it through a Samba share on another Windows PC :slight_smile:

When you enter the open directory dialog, just enter

\\yourserverip\sharename\conf\

This worked for me.

OUTSTANDING.

Short question: how to colorize the source code? I only see grey text…

Just make sure your file has one of the following extensions:

                "extensions": [
                    ".rules",
                    ".script",
                    ".items",
                    ".sitemap",
                    ".things",
                    ".persist"
                ],

It should work right away after you install the extension.

Hm… I realized that code --install-extension openhab-0.0.2.vsix didn’t worked for me. I had to install the vsix file via the extension menu within vscode.

Now it works with colors. That’s great.

T.H.A.N.K. Y.O.U.!

1 Like

Yes - but was thinking for the simulation of the sitemap, Visual Studio must know the IP where OH is running :slight_smile:

It takes it out of the information given by opening the folder.

Example:
On my Windows machine, I tell Visual Studio to open a folder and enter

192.168.0.xxx\openHAB\conf\   (with leading double backslash)

It then finds the subfolders and files to modify.
When I open one of my sitemaps and start simulation, it knows that my openHAB server has IP 192.168.0.xxx

1 Like

Open File->Preferences->Settings and add the openhab specific parameters:

{
“openhab.host”: “<your openHAB host>”
“openhab.port”: “8080”
}

I have added them to user settings.

I can confirm that the Sitemap preview also works on Ubuntu.

3 Likes

Ahhh, I was already wondering why it worked with version 0.0.1, but not with 0.0.2 anymore.
Thx!

@kubawolanin This is really excellent! I just installed it myself for the first time on my Mac to see what the fuzz is all about :slight_smile:

Even though we do not yet publish it in the official extension store, I would actually like to mention it as a great new feature (and possible alternative to the Designer) with the 2.1 announcement - any veto against this? Another question would be, if we should have a dedicated category here in the forum to discuss it - maybe a new entry in the Apps&Services category? Wdyt?

I feel the same way, great addition @kubawolanin! I can say that even without having tested the extension yet :smile:

@Kai I’d agree on both points.