openHAB VS Code Extension 0.1.0

What’s new

  • Completely new openHAB Items Explorer view in the sidebar!
    • Preview all of your items thanks to the REST API
    • Dynamic rules from the Items Explorer view - including the current state
    • Ability to copy Item’s name and state
    • Clicking non-Group item opens it in the Paper UI by default
    • Note: Currently in VS Code stable Items Explorer is permanently visible. VS Code Insiders allows you to hide the tree view thanks to vscode#29436
  • Added Items autocompletion (with IntelliSense documentation) (#7)
  • Quick search in the Community Forum
  • Added icon theme

items-explorer

Installation

This extension is not available in the Marketplace yet.
However, you can install it manually from official 0.1.0 release page.

  1. Download openhab-0.1.0.vsix 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

This version will override the previous one.

  1. Open Visual Studio Code
  2. Open openhab configuration (openHAB-conf) folder as your workspace
  3. Enjoy! :wink:
17 Likes

You’ve wowed me again! Nice work!! It’s becoming really simple to manage these text configs now!

Excellent stuff !

I uninstalled my Eclipse Smart Home Designer :slight_smile:

2 Likes

i am getting this error when i configure my openhab host :disappointed_relieved:

Error while connecting: 500 - {“error”:{“http-code”:500,“exception”:{“class”:“java.lang.NullPointerException”}}}

Solved: PROBLEMBETWEENARMCHAIRANDDISPLAY

There was a wrong item in my files, so http://openhab:8080/rest/items did also reply with the null pointer Exception.
So now. :grinning:

3 Likes

This is just great :heart_eyes:

FWIW, as an alternative to opening a commandline to install the extension, you can also use this menu: :slight_smile:

2 Likes

Please can you tell me how i can access this extension if i have installed like explained?

Do i have to start it with a shell command or can i start it directly from paper UI?

Do i need some other software installed to use this or is this a extension inside Paper UI?

I can answer myself: I have to install VSCode first, that´s an app from microsoft.

But one more question: Default url for openhab is “openhabian” with port 8080.

How can i change this? I´ve found the location inside vscode, but i don´t know how i can change the default values and save this?

Ctrl + , opens VS Code user settings. You need to modify it by adding openhab.port and openhab.host like so:

{
    "files.associations": {
        "*.log": "properties"
    },
    "window.zoomLevel": 0,
    "powermode.enabled": false,
    "workbench.iconTheme": "openhab",
    "openhab.host": "home",
    "openhab.port": "8080"
}

I just started with openhab2. This is a helpful plugin. Thanks!

What’s the latest status for code completion/“intellisense”? Do you have any plans to add more context based/object based code completion?

Hey Chad!

Of course, we do have plans to incorporate LSP.
But plan is not enough - we need execution :slight_smile:
So at the moment we’re waiting for @sjka’s Xtext upgrade to be available in eclipse smarthome.
After that’s done, we’ll need to integrate the VSCode extension with the LSP backend.
Here are some examples on how to approach this.

Cheers!

1 Like

Will the LSP incorporate symbols? I’d be nice if I could just press CTRL-R or use the @ command (Go To Symbol) to get an overview over all my rules in a rules file, items in items files, and so on.

What about peeking definitions of items, things, rules, and so on?

I will happily open issues for these feature requests, if those are not implemented through the LSP.

@kubawolanin How do i access the design pattern?

I really like the add on.

Thomas

If you look in https://github.com/openhab/openhab-vscode/blob/master/snippets/openhabrules.json
you’ll find all the shortcuts there, the design pattern is towards the end of the file.
So in a rule file, just type “dp time” (without the quotes) and return.

1 Like

How would I use it with myopenhab.org when I am not running the instance locally?
I entered

		"openhab.host": "https://myopenhab.org/",
		"openhab.username": "asdf",
		"openhab.password": "asdf"

but it seems not to work.

2 Likes

Shouldn’t it be port 443?
I have access to the file system because I sync them via cloud service to the target device. The target device is accessable through myopenhab.org.
All I want is proper syntax highlighting but it seems not to work without the rest API.