The pythonscripting binding for openHAB is the successor of the jython binding.
It is testet in openhab 5.1.x, 5.0.x and 4.3.x
Details can be found in marketplace for openhab 5.0.x and openhab 4.3.x
openhab 5.1.x already contains the latest version.
I made my own custom “toolbox” lib on top of it, where I’m not sure if the functionalities should be part of the openHAB helper library. Additionally, there are my own scripts, which can be used as examples.
Performance
I ported all my ~9000 lines of jython based python2 code to python3 which is now running with the new python binding. Everything works, but it looks that graalpy is 2-5 times slower then jython. If you run a pure python benchmark, it should be up to 4 times faster according to the graalvm devs. In openhab, however, most of it depends on the Python=>Java bridge, because there is a lot of interaction with java objects. This seems to be the reason for the “bad” performance. For comparison, I reimplemented some rules with the openhab-js binding and got similarly slow results.
Still, I think it’s acceptable because it’s more future-proof. It offers Python 3.x It offers more features than the Jython binding (e.g. dependency tracker, object wrapping for datetime objects, helper lib). And finally, I think it doesn’t matter if a script runs 0.1ms or 0.8ms
Most of my scripts run between 0.5ms and 8ms. More complex scripts have increased their runtime from 30ms to 60-70ms.
Credits
A lot of thanks goes to @jsjames . He helped, especially in the beginning, to deploy graalpy dependencies correctly. Without this help we would not be where we are now.
I also forgot to mention support from graalpy developers with a lot of helpful hints!