VisualStudio no autocomplete - OpenHab inside Docker maybe the problem?

Hi,
i installed VSC and the Addon. i configured the addon for VSC with the Port and the correct ip.

workplace config is empty. user config looks like this:
{

“openhab.host”: “http://192.168.178.80”,

“openhab.port”: 8180,

“openhab.useRestApi”: true,

}

when i directly try to open http://192.168.178.80/rest/items its working and its showing me sth.

in VSC i can see the things, but not the items. Also the autocomplete does not work at all.

i got into the docker container and gave the chown openhab:openhab to the complete openhab folder.

any ideas what could be wrong?

I’m assuming you’re using the official openHAB docker container.

I don’t see port 8180 being a valid port, are you sure that is correct?

i got it wrong in the first post…

http://192.168.178.80:8180/rest/items is working. i changed the port in the docker-compose cause the port 8080 is already taken on that server.

from the docker-compose.yml

    environment:
      OPENHAB_HTTP_PORT: "8180"
      OPENHAB_HTTPS_PORT: "8143"
      EXTRA_JAVA_OPTS: "-Duser.timezone=Europe/Berlin"

According to the docs you should not prepend the openhab.host with http://

So that would be:

{
“openhab.host”: “192.168.178.80”,
“openhab.port”: 8180,
“openhab.useRestApi”: true,
}

i tried that, but thats also not working… same issues

I just noticed that you have a trailing comma after true:

 “openhab.useRestApi”: true,

I’m not sure if that is causing any problem, but just in case I would remove it.

Then I found the following comment after I couldn’t get it to work myself (I’m using the official Docker container as well):

So you first need to open an .items file or a .sitemap file then in the left vertical icon bar you should see a new icon appearing. This icon is the openHAB logo. Click on it and you should see your items and things.

(It’s very well possible that it worked all the time for me but that I just didn’t notice the openHAB icon in the left bar)

The port you need to use is the Language Server Protocol port (LSP) which is 5007 by default.

This is not correct, for the “useRestApi” setting.
The lsp port has its own setting and should be set up to port 5007 on default.

openhab.port should indeed use the port which would be needed to access the rest api from browser.

1 Like

First teh basic stuff:
WHich version of the extension are you using?

So there are things visible in that tree view sidebar but the items area is completely empty?
Could you provide a screenshot for a better imagination?

This could indeed be reasoned to your lsp settings or reasoned in a not forwarded lsp port.
you could try/check the restCompletionssetting and set this to true, which should use the rest api for autocompletion.
if it is working with this et to true, we should focus on the lsp settings.

the newest versions of both, i just installed it.

i installed the docker container new, but with the original ports inside the container. i disabled the network host setting and forwarded the ports manually.

    ports:
      - "18080:8080"
      - "18443:8443"
      - "18101:8101"
      - "15007:5007"
   # network_mode: host

now it is working.

i tried all the other stuff you and all other forum posts recommended but nothing helped… , or not… lsp port, useRESTApi true or empty… nothing worked.

1 Like

So the docker image seemed to be the bottle neck. :thinking:
Interesting. I have heard the first time of such a behavior.

Anyways, fine that you could get it to work.

i guess so…it was a pretty fresh installation of openhab before, nothing configured much. now its also a complete fresh installation but i didnt configured anything port wise.
i also checked if my server got any traffic on the other used ports from openhab but thats not the case.

the mysterious thing is, that it was working via browser but the VSC cant open the REST Api.

Hi,

i just have a similar problem.

Openhab 2.4 in Docker on Synology, Host Mode

RestAPI, Code validation etc., items / things in sidebar, everything works fine since weeks

After playing around with weather Bindings, installing and uninstalling them several time suddenly the items don’t appear any more in the sidebar. Everything else works fine.

I cleared the cache and tmp file, reinstalled VSC, tried several PC, still unsuccessful.

I can see a blue clock over the extension logo (screenshot) and that remains there for hours.

settings.json:
{
“openhab.host”: “192.168.2.34”,
“openhab.port”: 8080,
“openhab.restCompletions”: true,
“openhab.lspEnabled”: true,
“openhab.useRestApi”: true,
“openhab.lspPort”: 5007
}

Any other idea?

Thanks

Frank

I would start by trying to determine where the source of the problem is by using a normal browser and opening the following URL: http://192.168.2.34:8080/rest/items

If this returns your items, then openHAB is working correctly and the problem must be on the Visual Code side. If it doesn’t return your items then the problem is in openHAB, Docker, or your Synology.

Hi Marcel,
thank you.

Opening that link I retrieve my items, no problems on that side. It is weird, that , if the problem is coming from Visual Studio, it is neither working on my Mac Book nor on a Linux PC.
Just reinstalled the docker container again, but still in host mode. Problem is still there.
Maybe I’ll try the bridge mode next.

I have following working version within docker official 2.4.0 release and VSC on a mac with openhab extension 0.4.1:

image

workspace settings vsc:

{
    "openhab.host": "vevedock-09",
    "openhab.port": 8080,
    "openhab.lspPort": 5007,
    "openhab.lspEnabled": true,
    "openhab.restCompletions": false,
    "workbench.iconTheme": "openhab",
    "openhab.karafCommand": "ssh openhab@vevedock-09 -p 8101 -t 'log:tail'",
    "git.ignoreLegacyWarning": true
}

compose yaml file to start openhab (ignore frontail and samba):

version: "3.2"

services:

  openhab:
    image: openhab/openhab:${OH_VERSION}
    network_mode: host
    ports:
      - 9125:9125
      - 9126:9126
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
      - /datavol/openhab-${OH_VERSION}/openhab_addons:/openhab/addons 
      - /datavol/openhab-${OH_VERSION}/openhab_conf:/openhab/conf 
      - /datavol/openhab-${OH_VERSION}/openhab_userdata:/openhab/userdata 
    environment:
      - OPENHAB_HTTP_PORT=8080
      - OPENHAB_HTTPS_PORT=8443
      - EXTRA_JAVA_OPTS=-Duser.timezone=Europe/Berlin -Xms400m -Xmx650m
      - CRYPTO_POLICY=unlimited
    labels:
      - com.df.notify=true
      - com.df.distribute=true
      - com.df.servicePath=/openhab/
      - com.df.reqPathSearch=/openhab
      - com.df.port=8080
  
  frontail:
    image: lukics/frontail:armv7
    command: ["/openhab/userdata/logs/events.log", "/openhab/userdata/logs/openhab.log"]  
    network_mode: host
    ports:
      - 9001:9001
    volumes:
      - /datavol/openhab-${OH_VERSION}/openhab_userdata:/openhab/userdata 
    labels:
      - com.df.notify=true
      - com.df.distribute=true
      - com.df.servicePath=/openhab/
      - com.df.reqPathSearch=/openhab
      - com.df.port=8080
   
  samba:
    image: lukics/samba:armv7
    command: ["-s", "mount-vevedock-${HOSTNAME};/datavol;yes;no;no", "-u", "lukics;.HardToGuess.", "-pn"]
    network_mode: host
    ports:
      - 139:139
      - 445:445
    volumes:
      - /datavol:/datavol
    labels:
      - com.df.notify=true
      - com.df.distribute=true
      - com.df.servicePath=/openhab/
      - com.df.reqPathSearch=/openhab
      - com.df.port=8080

starting it with:

export HOSTNAME
export OH_VERSION="2.4.0"
docker-compose -f openhab-compose.yml up -d

note: you should have a /datavol/openhab-2.4.0 directory existing on you server

to just make an additional note: It works like a charm. Openhab runs on a RPI3.
In the past I had a lot of performance issues. Now completition is almost instantly.

To display the items, only access to the REST API is required. I don’t know what the little clock on the openHAB icon means in Visual Code, but I can imagine that it means something like a timeout or that it is attempting to connect and that it is retrying this.

Could you try with the following config to see if the items show up?

{
“openhab.host”: “192.168.2.34”,
“openhab.port”: 8080,
“openhab.restCompletions”: false,
“openhab.lspEnabled”: false,
“openhab.useRestApi”: true,
“openhab.lspPort”: 5007
}

Thanks, I tried, still the same. :thinking:

I assume that there is something mixed up in on the item / thing files that the system runs into the timeout.

However, I don’t know where to look at
Files in jasondb looks fine, as far as I can see (which is probably not that far :wink:

@Confectrician Do you have any idea what the blue clock means?