OH3 Jython JSR223 import error for module joda

I start now to add the Ivan’s Helper Libraries to my openhab 3 environement.

mostly of all works well but module joda is requested if I fire the script. I learned that it doesn’t work anymore and must be changed to zoned.

But I don’t use any time request in my routine.

from core.rules import rule
from core.triggers import when
from core import osgi

@rule(“Monitor CavitiyTemperature”,
description=“Enable/disable rules based on the state of the CavitiyTemperature”,
@when(“Item SW_Monitor_CavitiyTemperature changed”)
@when(“System started”)
def SW_Monitor_CavitiyTemperature(event):

SW_Monitor_CavitiyTemperature.log.info("Turning {} Monitor CavitiyTemperature"

Monitor_CavitiyTemperature_RuleId = [rule for rule in rules.getAll()
               if rule.name == "Backofen - MonitorRule Status Zieltemperatur"][0].UID

ruleEngine = (osgi.get_service("org.openhab.core.automation.RuleManager") or
ruleEngine.setEnabled(Monitor_CavitiyTemperature_RuleId, items["SW_Monitor_CavitiyTemperature"])

Error :

[ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘573f480393’ failed: ImportError: No module named joda in at line number 2

It looks for me that the import of the core.trigger request the joda module but not needed into the the event itself.

Has someone any idea what must be changed ?


Make sure you’ve grabbed the right branch of the helper library. One of the breaking changes between OH 2.5 and 3.0 was removal of Joda. You need the “ivans-updates” branch.

Thanks for answer - I use OH 3 and the right library. I guess that the upgarde is missing. After install now the error was gone - many thanks Rich.


Now I run into the next problem where I can’t find any hint how to solve - only that it come up with OH 3.2 and all who posted it switch back to OH 3.1. Thats not a “real” solution for me.

2022-04-08 17:41:09.689 [WARN ] [jython                              ] - Traceback (most recent call last):

  File "/etc/openhab/automation/lib/python/core/log.py", line 96, in wrapper

    return function(*args, **kwargs)

  File "/etc/openhab/automation/lib/python/core/rules.py", line 108, in execute


  File "<script>", line 15, in SW_Monitor_CavitiyTemperature

IndexError: index out of range: 0

Logging itself was enabled via console.

Have someone an idea from where it comes up ?

many thanks

Yes, your rule. Can you share the rule that is causing this?


rule is posted in the first post here. Nothing changed.

Update: I’m some steps forward. I saw a thread with a discussion about item and itemname - in result it looks like that it doesn’t work - if I remove the select of the RuleID - it’s from my point of view simular and in result the error is gone and the script works in parts. Only the ON / OFF of the item state must be switch to boolean.

This is the corrected script, could be interest someone else.

→ removed, see last post

thanks to all for help, Christian

After some changes I will update the solution with the working version. There are some more changes necessary.

from core.rules import rule
from core.triggers import when
from core import osgi

@rule("Monitor CavitiyTemperature",
      description="Enable/disable rules based on the state of the CavitiyTemperature",
@when("Item SW_Monitor_CavitiyTemperature changed")
@when("System started")
def RU_Monitor_CavitiyTemperature(event):
    import time
    time.sleep(30) # Wait until all Rules are loaded
    RU_Monitor_CavitiyTemperature.log.info("Turning {} Monitor CavitiyTemperature"

    ruleEngine = (osgi.get_service("org.openhab.core.automation.RuleManager") or
    if items["SW_Monitor_CavitiyTemperature"] == ON:
      ruleEngine.setEnabled("c9d604d91b", True)
    elif items["SW_Monitor_CavitiyTemperature"] == OFF:
      ruleEngine.setEnabled("c9d604d91b", False)

This routine enable and disable based on a switch a dsl rule. It’s needed to trigger a device only in special situations.

With many thanks and respect for the creators of the helper library ! Often this will be forgot but without guys who spend a lot of time for find solutions like this a lot of possibilities are not there. Also Rich and all other who helps guys like me :slight_smile:

Bests, Christian

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