VS Code extension with openHAB Docker container

Hi all,
I would like to share some experience with you about using the openHAB VS Code extension and the problem I faced.

Problem description

In VS Code the openHAB Extension didn’t load although I properly configured the extension settings as well as had my openHAB config files (like .items) opened.

Solution

The openHAB VS Code extension expects to have the conf-folder as the root folder in your working directory of the currently opened VS Code window. So my current setup in VS Code is to open two fresh windows, one has my whole samba shared folder as the root folder and the second window has just the conf-folder of openHAB as the root folder.

Server setup

  • openHAB in docker container controlled by docker compose. Shared ports according to the docker compose configuration manuals. I shared port 8080 and 5007
  • samba client for sharing the directory where all files regarding my server setup are located. in one of the sub directories the conf-folder for openHAB is located

Why VS Code extension didn’t showed up

I mounted the samba shares and navigated through several sub folders to get to my openHAB conf folder. But the extension didn’t show up. The problem was, the VS Code extension for openHAB expects to have the conf-folder as the root folder in the current working directory of VS Code. Why, I don’t know.

@Confectrician I’m not sure if you are the right person to link here. I just saw you answering a lot of questions regarding the VS Code extension. Can I kindly ask you about your opinion on the described problem? :slight_smile: (if I should link someone else, please just let me know.)

If somebody else finds this information useful maybe there is a chance to integrate this information into the manual of the openHAB VS Code extension.

  • Add this information to the openHAB VS Code extension manual
  • Not necessary to add this information

0 voters

Some useful links to other VS Code extension problems and their solutions

https://community.openhab.org/t/items-things-trees-not-visible-in-vs-code-explorer-side-bar-with-oh-extension-0-4-0/52945
https://community.openhab.org/t/visualstudio-no-autocomplete-openhab-inside-docker-maybe-the-problem/73943

I do not have the need to load another root-folder in VScode for openHAB.

But I understand your issue.

Maybe a parameter can be added where users can define the relative path from the root-folder to the conf-folder.

Hi,

Sorry for joining late to the party.

openHAB uses some folders and files as a recognition point for activation and those expect the user to have opened the config-folder as root. That is correct.

There are other so called “activation events” too:

The last line is pretty important here.
If you open any openhab related filetype the extension should activate too.
(I can understand that this seems to be a bit late sometimes, of course.)

I am not sure, if a path prefix is the right way to go.
Maybe we should simply think about adding this to the docs an probably introduce a configuration to enable the extension globally on startup. (Not sure if this is possible, but we can find out if needed.)

You could also try to make your setup a “real” workspace configuration with multiple folders where one would be your non openhab-conf samba folder and another folder would be the openhab-conf as root.