Import error for core.util

I am having an issue with Jython. I am running OpenHABian 1.5/OpenHAB 2.5 on a Raspi 4. Jython is setup as explained here.

I have this rule for turning on my projector screen, when my chromecast exits idle state, which I copied mostly from here:

from core.rules import rule
from core.triggers import when
from core.util import sendCommandCheckFirst

@rule("Turn on home cinema", description="Turn ON the home cinema", tags=["home_cinema"])
@when("Item Chromecast_Livingroom_Idle changed from ON to OFF")
def turn_on(event):
    turn_on.log.info("Turned ON home cinema.")
    sendCommandCheckFirst("projector_screen", "ON")
    pass

Unfortunately I get this error:

[ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/python/personal/home_cinema_turn_on_rule.py': ImportError: No modu
le named util in <script> at line number 3

When I comment this line and comment out the call to sendCommandCheckFirst, the rule loads correctly, but then I cannot do anything.

from core.util import sendCommandCheckFirst

Help would be much appreciated!

Try core.utils :wink:

… and no need for this

2 Likes

:flushed: That was it of course. Thanks! If only it where always that easy … :sweat_smile: