JavaRule Java Scripting (SmartHome/J version)

[removed on request of the openHAB Foundation]

4 Likes

Now I finally have a reason to upgrade to openHAB 3 :slight_smile:

2 Likes

Is this different or the same as this?

Different. This one also works for UI rules.

Why did you create this bundle JNK? You forked the JRule repo and made changes and then created a new addon based on it? Why not add this support to JRule directly?

BR S

I originally started a fork, but found that what I had in mind (e.g. using the core data types) required something similar to a full rewrite (what you already guessed in our conversation). I then picked up my original approach (which I mentioned in the JRule thread) based on an external scripting engine and finished that one. If you check, this code has nothing to do with your code. The only idea I took from your code was building a library that the user can import.

We also have two JavaScript engines, why not two different Java engines? It was in no way meant to insult or offend you.

Ok thank you for the explanation, no insult taken was just curious why it looked similar with the annotations etc.

Would like to see those who want to write Rules using Java to team up so far 3 people have contributed to JRule, but know there are quite few more that are actually using it.

BR S

I can bring third one but without such stellar docs :slight_smile: and fast install options:. Sample rule: connectorio-addons/bundles/org.connectorio.addons.norule/src/test/java/org/connectorio/addons/norule/ActualCopRule.java at master · ConnectorIO/connectorio-addons · GitHub

To outline differences - above does not work with UI and allows “static” distribution of rules through JAR files.

1 Like

Documentation looks really good and clear and examples will be of a great help.

I will try it.

Could you please provide an example with a scheduled task inside a rule, this is the only point not fully clear for me.

1 Like

I would like to know if there are plans to include that in the official openHAB distribution ?

And for shared variables between several rules, I imagine a specific class with variables as members, referenced in each rule class?
Maybe an example would be welcome.

1 Like

I have updated the examples: Java Rule Automation. This will be included in the next release