Is there an IDE that gives compile-time errors for openHAB rules?

Tags: #<Tag:0x00007efecb81b638>

I’m using Visual Code to edit rules, but it doesn’t show compile errors like IntelliJ/Eclipse does for java. Does any IDE do that?

None convincing are listed here: https://www.openhab.org/docs/configuration/editors.html

Can Eclipse SmartHome do that for rules and such stuff? Any guide? I found this, but I’m not quite sure it is what I’m looking for: https://docs.openhab.org/v2.1/installation/designer.html

I also posted here for QnA: stackoverflow

I think designer is quite old

1 Like

Rules DSL doesn’t compile. They are parsed and VSCode does show parsing/syntax errors if configured correctly. Errors that would normally be detected at compile time will be runtime errors with Rules DSL (and most scripting languages frankly).

When using VSCode with the openHAB extension properly configured to use the LSP server running on an OH instance, the editor will use literally the exact same parser that OH uses when it loads the .rules files. Any warning or error logged by OH when it tries to load the .rules file will appear in VSCode as you type.

ESH Designer is long since abandoned and never really worked well for OH 2. And even it did no more than what VSCode’s openHAB extension does, only it implemented its own parser which never was as thorough, complete, or helpful as the errors produced by openHAB itself.

tl;dr: VSCode with the openHAB extension (properly configured) is the best and only option for Rules DSL.

Because the question is worded differently on StackOverflow, you will find further details there.

Thanks for the help Rich, I’m sorry I’m so late to respond, I got completely sidetracked elsewhere.

I do have the server running, and connected in VSCode. If I write ‘T’ then Ctlr-space, I get a list of my items starting with T and containing T. However I don’t get any compile like errors or IDE warnings.

Also I don’t seem to have that nice java-ide context sensitive completion where if I write an object (or item) such as SqueezeLastAuto.stat and click C-space, it will help me to autocomplete to state and tell me of other methods available on the object.

Is it correct that these things don’t exists for openHab rules? I guess that would make sense, since that level of IDE typically comes late to the party, as its more important to have a stable language than a nice IDE.

I think the answer to my stack overflow is no (given what you wrote here), with the additional helpful details you gave in the answer. Because the question is about whether such an IDE with compilation exists, and here you said no. Will you update the answer, then I’ll accept it with a thank you? If not I’ll probably just wirte a not and link here, to close it.

Best Alex

I’m not certain that VSCode uses ctrl-space for code completion. I just pause half a second and it pops up with completions.

It should mark errors in the text editor. Any error you see in openhab.log from your scripts should be shown as problems in VSCode.

But you must configure the extension properly. So far you have not mentioned that you have done any configuration of the extension. At a minimum you must tell it where your OH is running so it can access the LSP server to do the code syntax checking.

But it’s also important to understand that Rules DSL does not get compiled like C++ or Java does. It’s a scripting language. It get’s parsed and loaded into memory and gets executed from memory by an interpreter.

That is not correct. VSCode will tell you any syntax errors that exist in your .rules files as you type. It will also do code completion and tell you all the methods and members of a class. But only if you have it configured to point to an actively running instance of openHAB and it can access the LSP networking port. The actual syntax checking is done on OH itself, not within VSCode.