OH3: automation scription Jython

Hello,
I’m somehow stuck somewhere and would highly appreciate some hints and questions to move forward.

What I want to do is to use Jython scripting for all my rules and functions to implement. Searching addons as well as community I found two subjects:
a) “Jython Scritpting” addon; installation easy and it works; script developed using the buildin editor in OH UI
b) found on Github “openhab-scripters” https://openhab-scripters.github.io/openhab-helper-libraries/Getting%20Started/Installation.html

Point 1 to 9: ok
Point 10: found the my “start.sh” in folder “/usr/share/openhab”
When setting up the “bootclasspath”, “python.home” and “python-path” it seems I’m stuck.

Jython 2.7.2 installation: “/opt/jython”

/opt/jython $ ls
ACKNOWLEDGMENTS       Demo        Lib                  LICENSE.txt  registry
bin                   Doc         LICENSE_Apache.txt   NEWS         tests
CoreExposed.includes  jython.jar  LICENSE_CPython.txt  README.txt

Here is what I added at top of “start.sh”:

export EXTRA_JAVA_OPTS="-Xbootclasspath/a:/opt/jython/jython.jar -Dpython.home=/opt/jython -Dpython.path=/opt/jython/Lib"

When I place a simple script under folder “/etc/openhab/automation/jsr223/python/personal” I can not find the script somewhere in the UI or being executed.

Script in UI editor, “simpletest”:

from org.slf4j import LoggerFactory

LoggerFactory.getLogger("org.openhab.core.automation.examples").info("Hello world from UI scripting!")

Script in folder personal, “test.py”

from org.slf4j import LoggerFactory

LoggerFactory.getLogger("org.openhab.core.automation.examples").info("Hello world from Python IDE!")

Thanks in advance. Now going to have a good wine, maybe this helps too.
Bernhard

Maybe I missed it - what version of openHAB?

For OH2&3, all you need is explained in this post:

Hi, thanks for help. I followed the steps as indicated by Ivan. It worked after restart of openhab service.
As of now it seems to work using the hello_world.py example. :slight_smile:

What I’m a bit confused with is the fact I created a new file with identical content (using different rule name…) in the personal folder, but this file is not loaded.

Bernhard

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.