OpenHAB 5 jython rules issue after upgraded from 4.3

I just Updated from OpenHAB 4.3 to 5 and all rules defined in /etc/openhab/automation/jsr223/python/personal

are not loaded anymore and not work.

Was there a Breaking change?

Additional Information:

Jython is still installed, I deleted Java opts in /etc/default/openhab because not needed anymore.

Found out, Directory for scripts changed from automation/jsr…. To automation/jython

now OpenHAB tries to load Rules but Arend to have issues with helper libraries???

unable to load Module core not found

2025-07-31 14:49:15.316 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script ‘/etc/openhab/automation/jython/010_Alarm.py’: ImportError: No module named core in /etc/openhab/automation/jython/010_Alarm.py at line number 3

further failures to Import central Configuration.py

maybe the files are just in wrong directories?

The lib path is /automation/jython/lib. Just put your helper libs to this folder. More details can be found here

The related breaking change was during the openhab 4.2 release. Also the change from automation/jsr223 to automation/jython was happens there.

But maybe its time to give python3 a try :-). The only bad news there is, that the helper libs, you are talking, are not working there anymore. As a replacement you have a very lightway new helper lib.

1 Like

Hi Holger,

thank you for your support. I found the link but didn’t find where to place the helper files. But with your hint I got everything up and running again.

Will have a look on python3 later.

Again: Thank you.

1 Like

I seem to be having the same issue, but I don’t get it working.

I’m coming from OH 4.1 jsr223/python with some helper lib (named core) installed - plenty of rules.

I read through this solution, but I keep getting
ImportError: No module named core in /home/openhab/openhab-config/conf/automation/jython/z-solaredge.py at line number 1

I copied the helper lib from automation/jsr223/python/core to automation/jython/lib (so there is now a core directory in the jython/lib dir that contains the 000_Startup.py and a components subdirectory.

when starting up, I already don’t get the output that’s done by the 000_Startup.py, but in addition I get the ImportError as stated at the beginning.

This sounded to be the same problem, if not I’m sorry for the noise here.

For me it worked just to move scripts to new place. Did you already tried?

assuming you are talking about my custom scripts, this is the z-solaredge.py script that is mentioned above (I tried this as a starter), but sadly it doesn’t work due to that missing ‘core’ module.

btw, my script starts with those imports:

from core.rules import rule
from core.triggers import when
from java.time import ZonedDateTime
from java.time.format import DateTimeFormatter
from java.time.temporal import ChronoUnit
from core.actions import PersistenceExtensions as pe
from core.actions import ScriptExecution
import math

I think the missing part is the openhab-helper-libraries, which AFAIR should be this: openhab-helper-libraries/Core/automation/jsr223/python at jeff · jsjames/openhab-helper-libraries · GitHub

I putted then under /etc/openhab/automation/jython/lib/core

Init.py is under

/etc/openhab/automation/jython/lib/community

hi,
that was it - thank you a lot!

so I guess now it’s time to gradually migrate to the new python3 rules…

1 Like

I have noticed that some people have problems downloading the correct packages from the openhab-helpers-libraries. This results in errors because some paths are incorrect. To avoid confusion, here are some instructions that work:

Installation

Required tools

At first you have to install:

sudo apt install -y git sshpass

Cloning the repository

cd ~
git clone https://github.com/Michdo93/openhab5-jython-helper-libraries

Installing the Jython Scripting binding

sshpass -p habopen ssh -p 8101 -o StrictHostKeyChecking=accept-new openhab@localhost 'exit'
sshpass -p habopen ssh -p 8101 -o StrictHostKeyChecking=no openhab@localhost 'feature:install openhab-automation-jythonscripting'

Configuring Python Path

You have to run:

sudo systemctl stop openhab
sudo sed -i '/^EXTRA_JAVA_OPTS=/d' /etc/default/openhab && echo -e 'EXTRA_JAVA_OPTS="\n  -XX:+UnlockExperimentalVMOptions\n  -XX:+EnableJVMCI\n  -XX:+UseG1GC\n  -Dpolyglot.engine.WarnInterpreterOnly=false\n  -Dfile.encoding=UTF-8\n  -Xms256m -Xmx1024m\n  -Dpython.NativeModules=false\n  -Dpython.ForceIsolation=false\n  -Dpython.home=/usr/share/openhab/runtime/lib/python\n  -Dpython.path=/etc/openhab/automation/jython/lib:/etc/openhab/automation/jython/modules\n"' | sudo tee -a /etc/default/openhab
sudo rm -rf /var/lib/openhab/tmp/* && sudo rm -rf /var/lib/openhab/cache/*

You should see something linke this:

EXTRA_JAVA_OPTS="
  -XX:+UnlockExperimentalVMOptions
  -XX:+EnableJVMCI
  -XX:+UseG1GC
  -Dpolyglot.engine.WarnInterpreterOnly=false
  -Dfile.encoding=UTF-8
  -Xms256m -Xmx1024m
  -Dpython.NativeModules=false
  -Dpython.ForceIsolation=false
  -Dpython.home=/usr/share/openhab/runtime/lib/python
  -Dpython.path=/etc/openhab/automation/jython/lib:/etc/openhab/automation/jython/modules
"

As you can see, performance optimization for GraalVM and GraalPython has also been carried out here, as it is recommended to migrate to Python 3 binding. However, this requires that GraalVM is also used for openHAB 5.

Copying the openHAB Helper Libraries to your automations folder

cd ~/openhab5-jython-helper-libraries
sudo cp -r automation/ /etc/openhab
sudo chown -R openhab:openhab /etc/openhab/automation
sudo systemctl daemon-reload
sudo systemctl start openhab

For those who still want to use their old scripts, it is advisable to move them to another directory, perhaps temporarily.

How do we say it jokingly in Germany? Well? Are all clarities removed? (The right sentence is: Are all ambiguities removed?)

Kind regards,
Michael