Here is a quick and dirty how-to for getting the JSR223 Jython working with OH in Docker.
These instructions do not require modifications to the official Docker image.
WARNING: I’ve not gone any further than seeing that the empty test.py script is seen and loaded.
See the JSR223 docs for details.
-
Download and install Jython to some directory that gets mounted into your openHAB volume. It seems feasible that the stand alone jar file might work for this but I did the full install. I chose /opt/openhab2/conf/jython as this is directory that gets loaded into the container under /openhab/conf.
-
Create a folder to store any Python libraries and packages you will want to be available to your Jython rules. I chose /opt/openhab2/conf/lib/python.
-
Whatever you use to start the openHAB container, (Docker-Compose, Ansible, by hand) you will need to add the following environment variable to the container:
EXTRA_JAVA_OPTS="-Xbootclasspath/a:/openhab/conf/jython/jython.jar -Dpython.home=/openhab/conf/jython -Dpython.path=/openhab/conf/lib/python"
where /openhab/conf/jython and /openhab/conf/lib are replaced with where ever you mount the jython and lib folders we just created is located.
-
Create /opt/openhab2/conf/automation/jsr223 folder which will hold the scripts.
-
Create an empty test.py file in conf/automation/jsr223.
-
Start the openHAB container with the new environment variable option and watch the logs. You should log entries showing that python, ECMAScript are enabled and a line showing test.py being loaded.
-
Install the Experimental Rules Engine.
I’d love to hear if someone tries using just the stand alone jar file or further experiments.
EDIT: Added step 7 as the Experimental Rules Engine is required to run JSR223.