VS Code openHAB Extension!

syntax
ide
vscode
Tags: #<Tag:0x00007f6cf1b12140> #<Tag:0x00007f6cf1b11e70> #<Tag:0x00007f6cf1b11c18>

(Udo Hartmann) #183

Take a look at the folder /var/lib/openhab2/etc/

There should be at least 2 files named org.ops4.pax.logging.*, one with ending cfg, another with dpkg in it. just rename the .cfg to .cfg.old and the .dpkg* to .cfg (i.e. replace the old file with the new one)


(Jonas) #184

Hi! I found this when i was searching for syntax highlighting and autotextcompletion. First of all i want to say thanks for that great work! It is already showing my files in the correct color. Unfortunately i have to connect to the folder manually every time. i read the post, where the autoconnect is explained but i can’t get it working. I’m editing from my mac and connecting to my raspberry via smb. in my workspace setting i wrote:

{
“folders”: [
{
“path”: “/Volumes/openHAB2-conf”
}
],
“settings”: { “settings”: {
“openhab.host”: “openhabianpi.local”,
“openhab.port”: 8080
"openhab.useRestApi": false
}}
}

one thing i noticed there is that it can only connect when i activated the volume prior. when i change the path to:
smb://raspberrypi/openHAB2-conf
it’s not working at all.
what am i doing wrong?
Sitemap previews are not working either.

I never used visual studio before so please excuse my noobish questions. :slight_smile:


(Udo Hartmann) #185

Please try

smb://openhabianpi.local/openHAB2-conf

instead.
VS Code is NOT Visual Studio! :slight_smile:


(Jerome) #186

I think we need a meme for that. :smile:


(Jonas) #187

yeah i know. that was not clearly written from me. i downoaded vs at first but then i recognized and got the right program (after following the OH extension to the store) … i’ll try later, thank you!


(Jonas) #188

Hi there!

It worked - partly :wink:
I am connected now (after i recognized that the quotes can’t be copy/pasted correctly) even after i restart the program.
but i can’t get the rest api working.

my code:

{
	"folders": [
	{
	"path": "smb://openhabianpi.local/openHAB2-conf"
	}
	],
	"settings":{
	"openhab.host": "192.168.178.90",
	"openhab.port": 8080,
	"openhab.useRestApi": true,
    "openhab.username": "openhabian",
    "openhab.password": "openhabian"
	}
}

i tried the ip adress as host as well as openhabianpi.local

regards

jonas


(Jerome) #189

What does "can’t get rest API working’ mean in detail?

If you just don’t see items and things explorer, the extension simply might be initiated yet.
It does not initiate with the start of VSCode.
You have to open at least one openHAB config file (items/rules/things, doesn’t matter which special type) or make it to the “active tab” by clicking into the editor.
At this time the openHAB extension will init itself and connect to rest API.

If you have another problem occuring some details would be good to give a more precise answer. :slight_smile:


(Jonas) #190

You are right, that was not a good issue description :slight_smile:
I try to see the Sitemap preview and when i click there VSC gives me the following:
Error while connecting to openHAB REST API.
And i don’t see the preview but only white color when i click the openHAB icon.
I can access the sitemap as well as the rest api directly with my browser.


(Jerome) #191

Ok that’s something to work with. :slight_smile:

Are you using “basic auth” for your installation or ar this the credentials for e.g. connecting to openhabain reomtely like you would do with a raspberry pi?

If you aren’t using basic auth or don’t know what i am talking about now
try setting it up this way:

"openhab.username": "",
"openhab.password": ""

(Jonas) #192

which password is this? when i connect via terminal to my raspberry i connect to:
ssh pi@raspberrypi.local
then when i want to access the OH console i type:
ssh -p 8101 openhab@localhost
or do you mean another password?

I don’t know which userdata is needed here …

Thank you!


(Jerome) #193

Try it exactly as I posted above with no user and password data.

Those settings are only needed if you have enabled an additional security layer.


(Jonas) #194

not working :frowning:

i am editing the Workspace-Settings, right?
I recognized another settings file in the OH-Config Folder:
.vscode and there settings.json.
but that one is empty.


(Jerome) #195

Same error message?


(Jonas) #196

yep


(Kuba Wolanin) #197

@Jonas88 please try the extension from this post:

The fix from there is not released yet.
Read the VSCode docs on how to install an extension manually.


(Jonas) #198

thank you! I’ll try it :slight_smile:
Edit:
now i am getting a new error:
Error while connecting to openHAB REST API. getaddrinfo ENOTFOUND openhabianpi.local openhabianpi.local:8080


(Carlos Roa) #199

How do you enable additional security layer?


(Jonas) #200

Hello! After using the IP adress of my Raspberry instead of openhabian.local as host it worked.

Edit: Not true.
I can now use the preview of my sitemap but i still get the error:
Error while connecting to openHAB REST API. connect ECONNREFUSED 127.0.0.1:8080


(Kuba Wolanin) #201

Could you try placing the config in the user settings instead of workspace settings?


(Jonas) #202

Hi!

Got it working now :slight_smile: Thank you!
Here is my config for Workspace and User: