Port JSR223 bundle to openHAB 2

Tags: #<Tag:0x00007f18277d9380> #<Tag:0x00007f18277d9100>

(Sebastian Janzen) #1

Hi @helmut_lehmeyer

I’d like to port the JSR223 bundle to openHAB 2. I saw some incompatibilities, but it should not be very hard.
Did somebody already started on this?


(Helmut Lehmeyer) #2

Hi @sebastian,

very interesting! If you need help I am ready at any time.

[Did you read this discussion about JSR223?] (Https://github.com/openhab/openhab/pull/2378#issuecomment-88241590)
Especially OH2 Scripting.
In connection with OpenHab 2 and scripting @Kai can enlighten policy?

So far I have only found that JSR223 in OH2 just not running.
Where are the incompatibilities?


(Sebastian Janzen) #3

Basically, some packages have moved to eclipse smart home. But I’ll read your link laster this day, thanks!

(Kai Kreuzer) #4

@sebastian, Maybe you have forgotten about it, but we both spoke about this already not long ago.
I am currently starting trying to port JSR223 to ESH on the new rule engine. I am hoping to have something working in a few weeks time, I’ll keep you all posted.

(Petr Klus) #5

@Kai, @sebastian - this is amazing news! I’ve just recently stumbled upon this development but I cannot wait for this to be official & part of the OH2!

To explain my excitement - while I do appreciate the current rule engine for very simple tasks, it can get unwieldy pretty soon (just imagine locks or anything from the Java world) and just loses the simplicity when “proper” Java classes need to be used. Python, for example, has a huge standard library of functionality and I am confident that I can simplify my rules A_LOT if I had the flexibility of Python.

Not to mention the barrier of entry for beginners - pretty much any basic Python question is answered via SO or similar sites - sadly, this cannot be said for Xtend…

Anyway, just wanted to thank you both for your effort - if the vision of OH is to be scripting-language agnostic as well, we have bright future ahead of us!

(Kai Kreuzer) #6

@petr, I am actually hoping that @smerschjo joins in after I have created the initial work, so the kudos go to him for doing all that work for openHAB 1 initially :+1:

(Helmut Lehmeyer) #7

@Kai, are there any news? What is the current status? :yum:


(Kai Kreuzer) #8

Yes, I have an initial version implemented within the new rule engine and specifically made Javascript working there.
The PR is https://github.com/eclipse/smarthome/pull/317 - it is currently waiting for Eclipse IP team approval, but I am still lacking the CLA of @smerschjo - Simon, if you read this, please make sure to sign it soon, otherwise we are blocked!

(Michael Weller) #9

I’m not able to catch the result of this topic and its links…
Is the javascript rule engine for openhab 2 somewhere available right now for testing?

Rule actions in OH2 javascript. Where can I find informations about the API (items, busevents, timer, log) available inside the script?
(Helmut Lehmeyer) #10


  1. install openHAB2 Snapshot
  2. Go to the Paper UI -> Configuration -> Services -> Extension Management and
  3. enable “Access Remote Repositories” and ‘Include Experimental Extensions’ and save.
  4. goto PaperUI -> extensions -> MISC -> RuleEngine(Experimental) -> install.

After installation you get Rules Item in PaperUI left-menue:

In “Actions”, there you can configure javascript engine too:

(Michael Weller) #11

Just my OpenHAB 2 / paper ui is missing all script engine related items.

Locks as if I didn’t catch the lastest Version?
Just to be sure, where should I get from??

(Helmut Lehmeyer) #12

Now I found Kai’s original post.

Missed “Enable “Access Remote Repositories” and ‘Include Experimental Extensions’ and save”

(Michael Weller) #13

Thanks a lot!
I now I found it.

I’m going to port some script rules from 1.8.3.
Can you give me any hint are the scripts are stored? I need to edit the external, because they are to complex for this integrated UI.

Is the object model / api similar to 1.8.3 ?

(Helmut Lehmeyer) #14

Puhhh, I’m in the same Situation. It is for me not as comfortable doing it by a GUI. I have complex javascripts and have external javascript libraries which I can load very simple in jsr223.

Because it is experimental and not “the last word”. I wait to port at the moment.

I did not test it, don’t know if the object model / api is similar. I would study the Sources to find out.

(Daniel Walters) #15

For some reason I don’t get the Rules section in the Paper UI menu even after a refresh.

Any ideas?

(Helmut Lehmeyer) #16

I have installed yesterdays version, and got an error too, Bundle is not starting.
Yes, its experimental.

(Sebastian) #17

Are there any news on this?
I have lots of rules running very well in jython and slowly I am thinking about OH2.
Is there now full support of JSR223 (+jython)?

(Ashley Reid) #18

This is a bit of cross post from Excellent presentation of Kai at jPrime conference: Recording somewhere? because that has the best example I have found to start with these types of scripts.

It would be good to have some basic API/debug starting points to get us started on using this more effectively.

(Petr Klus) #19


Just checking what is the progress on this - is there any basic tutorial/set of steps needed to get this to work?

Would be great to start using Python in rules!

(Sebastian) #20

Anyone? I am still waiting for jython and jsr223 so I can move over to OH2.