VS Code openHAB Extension!

Oh, and it utilizes REST API!

Sounds excellent :slight_smile:

Here we go: VS Code - openHAB Community
Keep up the good work!

I’ve noticed a small bug.

I have a few items which use an icon called switch. This highlights pink, even though its within < >. All other icons are highlighted white.

Eg

Otherwise the whole experience of using VS has been extremely good. Very nice work!

Hey Paul, thanks for reporting!
Could you raise an issue on projects GitHub?
Cheers

Done.

I added it there to keep the repo issues up to date. :slight_smile:

Thanks very much.

Head’s up! There’s a new version of the extension - 0.1.0:

Feel free to continue discussion on the new thread :slight_smile:

5 Likes

This is just great. Even though it’s a pre-release, it’s way more suitable to be the official editor than openHAB Designer. It just has the ultimate feature that designer doesn’t have: Creating new files :joy:

CTRL-N would have solved that problem :grin:

OK, in this case I go for customizability, Git support and an acceptable startup time :grinning: The only thing I miss is autocompletion for the rules API.

2 Likes

Hi @kubawolanin,

When trying to access suggestions via ‘Ctrl+Space’, I get the following error:
Error while connecting: Error: getaddrinfo ENOTFOUND openhabianpi openhabianpi:8080
Is this a bug?

Thanks,

George

The completions service is tightly coupled with the REST API of the openHAB, so in order to get them, you need to edit your user settings in VS Code ( Ctrl + ,) and add the following parameters - openhab.host and openhab.port (optionally).

Your settings.json might look like this:

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

Do you think that error checking for sitemaps and things/items files would be a possibility in the future? I think this is the only feature that the smarthome designer has over the VS code extension.

Absolutely! This is something that Language Server Protocol would take care of. I’m looking forward to work with volunteers willing to implement that! :wink:

Awesome, I did see that issue but it’s marked for Xtend. I’d guess that it’s a little more difficult to do it with the unique formatting of Items etc which would probably need it’s own LSP right?

Either way, exciting times!

Thanks,

I missed that!

It works now!
If it’s not a big effort for yourself, could you add in the readme that the url for the hostname can also be an ip address (i just tried it and it works!)?

George

I have requested the readme change, since this is a useful information :slight_smile:

2 Likes

I’m sorry I did not get how did you install the extension on MacOs

Thanks

@Dominic_Bonneau I believe it is the same for osx as it is for windows.

Open the extensions pane on the left, then open the options menu (three dot) link at the top. Choose to install from VSIX and then navigate to where you saved the vsix file.

Thanks for this, I use a text editor for writing my rules because the SmartHome designer is not good. This is a welcome change and I am willing to download VSCode, but I was wondering what would be required to make this compatible with other Visual Studio editions, I’m currently using VS2015 Pro.

I think it is currently not possible to make it compatible with other VS products.

As far as i know, the only thing that those extension types have in common is the .vsix file ending.
Nothing more. :smiley: