VS Code openHAB Extension!

syntax
ide
vscode
Tags: #<Tag:0x00007f6cf061cee8> #<Tag:0x00007f6cf061c8d0> #<Tag:0x00007f6cf061c088>

(SiHui) #143

Don’t open the rules folder directly, open the conf folder of your openHAB.
And don’t forget to change the settings:

{
    "openhab.host": "192.168.x.xxx",
    "openhab.port": 8080
}

(Udo) #144

just tried it - VS Code openHAB Extension - looks great - thx for the good work


(Becksen) #145

Thanks, works now.


(Weakfl) #146

Works great, thanks!


(dimes) #147

Is or will it be possible to use VS Code with myopenhab? To change/operate the items/sitepam remotely?


(Kuba Wolanin) #148

@dimes Never tried that but I don’t think that’s possible, given that you need an access to the file system in order to read and write to the files.

In the next version of the extension you will be technically able to access the Items and Things. Note that LSP (content assist for rules and syntax validation) won’t be exposed, so you’ll need to disable it too.

    "openhab.host": "https://home.myopenhab.org",
    "openhab.port": 80,
    "openhab.lspEnabled": false,
    "openhab.username": "your_myopenhab_email",
    "openhab.password": "your_myopenhab_password",

Here’s the commit that adds that feature.


openHAB VS Code Extension 0.1.0
(h.j.) #149

ive noticed following problems since upgrade to oh 2.2.0 rel:

every first statement of each rule-file is marked as a problem with this strange hint of a “type is already defined in…” ive never defined. no matter whether the first statement is a var or an import.
is there something im missing creating a rules-file? some syntax issues or maybe a permission prob?

system:
synology dsm 6.1.4-15217-3
openhab as docker container based on latest “2.2.0-arm64-debian image” from 21.12.17


(Kuba Wolanin) #150

@rikky could you please submit a new issue on ESH repository? @sjka would you mind taking a look?

cheers


(h.j.) #151

(Andreas B ) #152

Hey,

first - thank you for that great extension.

I got a problem with the Rest API. My configuration is the following:

{
    "openhab.host": "192.168.X.XXX",
    "openhab.port": 8080
}

It always says “Error while connecting to openHAB REST API.”. If I open “192.168.X.XXX:8080/rest/things” in chrome I do see everything.


It is solved… Juist reopened Visual Studio Code and it is not showing that error anymore… So for everyone else being like me - just restart Visual Studio Code.

Other question: I got my openHAB-Pi in an own network. Do I have to forward 5007 TCP/UDP or TCP & UDP?

Thank you so much in advance!


(Ingo) #153

I was excited to see I could still run it on Linux. But unfortunately it seems to be totally broken when running on Linux but displaying to a VNC server/client combo. Very odd behavior, such as not being able to use certain keys, like the number six key (with or without shift).

Any ideas how to get past that? I’ve tried both RealVNC and TightVNC clients on Windows, Tight works better than Real, but still misses some things. All my other Linux apps work perfectly.


(Ingo) #154

How do I tell VS Code where my code lives?

When I go to one of my rules and right-click on a variable, selecting “Go to Definition” gets me an error message:

Unable to open 'motion.rules': File not found (file:///etc/openhab2/rules/motion.rules).
Create FileCancel

Why is it defaulting to /etc/openhab2 when I opened it from \\server\openhab?

I’m running VS Code on Windows with the 0.3.5 version of the extension. OpenHAB2 runs on an Ubuntu Linux box, the REST API is configured and works without error. The files are served to my Windows box via Samba.

I’ve tried restarting VSCode, opened new workspaces, etc… but I’m at a loss.


(Udo Hartmann) #155

Did you use “open folder” (in german “Datei->Ordner öffnen…”)? I’m using a mapping, but it’s also possible to use the UNC path. You should open \\server\openhab-conf\ as folder (the samba share should provide /etc/openhab2/ to this share)


(Ingo) #156

Yes, I was browsing to a UNC path \server\openhab which is a Samba export of /etc/openhab2

When I right-click Go to Definition on a variable, I get messages like:

Unable to open ‘freezer.rules’: File not found (file:///etc/openhab2/rules/freezer.rules).

No difference if I first map the drive and use the mapping.

I can successfully create and edit files in the folder via Code. The permissions are correct, as are the owner.


(wolf_from_the_north) #157

after doing the settings in vscode you have to reboot vscode to make them active else the connection to the rest api does not work


(Ingo) #158

Do you mean do File->Exit on the windows vscode session and start it back up? I’m doing that, but no changes. Or do you mean restart something on the OpenHAB server?

Another interesting thing, when it can’t find the file, it allows me to create one. Even though I opened Z:\ (or \server\openhab), it creates the new file locally in c:\etc\openhab2 on the Windows machine, totally ignoring the local source path, but using the remote source path instead as if it’s local.

My REST API comms are working, I’m seeing the items in the TREE view. It’s just this infernal path thing.

openhab> bundle:list | grep Language
138 │ Active │ 80 │ 0.10.0.b1 │ Eclipse SmartHome Language Server

Adding @kubawolanin


(Kuba Wolanin) #159

@idean I can’t help much, the Language Server part is being developed on Eclipse SmartHome.
cc: @sjka


(Ingo) #160

Thanks, as far as I can tell, the Language Server is working well. It’s just that VSCode is trying to open local files instead of the real path on the Samba server.


(Karel Goderis) #161

I see a lot of these

[Error - 16:19:36] Request textDocument/hover failed.
Message: Internal error, please look at the server’s logs.
Code: -32603
[Error - 16:19:36] Request textDocument/hover failed.
Message: Internal error, please look at the server’s logs.
Code: -32603
[Error - 16:20:27] Request textDocument/hover failed.
Message: Internal error, please look at the server’s logs.
Code: -32603

messages in the log of Visual Code. When I enable TRACE on org.eclipse.smarthome.model.lsp nothing shows up in the server logs.

What might be the problem here?


(Karel Goderis) #162

Ok - I found https://github.com/eclipse/smarthome/issues/4459.