Let’s see if we can get to the bottom of the error. First question, what version of openHAB do you have installed? You should be running a recent 2.4.0-SNAPSHOT or the latest 2.4.0 milestone build.
So the hello_world.py you are trying to run is a copy of Script Examples/hello_world.py, which in turn is from the master branch Zip archive that you downloaded from GitHub. My guess (with little evidence to support my guess) is that you do not have a JSR223 startup delay script in place and all of the Jython support modules were loaded before OpenHAB’s JSR223 automation machinery was “ready.” On my system I have the file 000_0_delay_startup.py located in /etc/openhab/automation/jsr223/ that prevents the Jython support modules from loading until the JSR223 scripting subsystem is ready to go. The contents of that file are:
from org.slf4j import Logger, LoggerFactory
logger = LoggerFactory.getLogger("org.eclipse.smarthome.model.script.Rules.jsr223")
logger.info("Startup: Checking for initialized context")
if automationManager != None:
logger.info("Startup: context initialized... waiting 30s before allowing files to load")
logger.info("Startup: Context not initialized yet... waiting 10s before checking again")
Try creating a copy of this script named 000_0_delay_startup.py and place it in /etc/openhab2/automation/jsr223/. Once you have done that, restart your system.
There is a thread here in which this is discussed. I’ll track it down and add a link in this reply when I find it. Found it,
I’m running openHAB 2.3 release build (on RPi 0W if it makes any difference), I already encountered the problem with modules loading and have the delaying script in place and running, even with the same code as yours because I got my code from the linked thread I will read trough it again.
I switched to latest snapshot version, got some errors and OH didn’t even loaded all modules, seeing that I just switched to the milestone build - 2.4.0.M5, added again EXTRA_JAVA_OPTS because they got deleted, reboot and it hello_world is working!
If I will have some questions regarding rules I am about to write should I just post them here or start new thread?
Glad you got everything sorted! I’m still puzzled by the error you were getting though, since the only way you could get this error is if I mistakenly updated files in master, or if you were using files from the restructuring branch. I’ve searched all of the file in master, but do not see any reference to ‘core’, so it must have been the latter. Were you definitely only using files from master?
It’s odd for me to see that error, since I was just seeing the same one when renaming the openhab package. But you’re right… from org.eclipse.smarthome.automation.core.util import TriggerBuilder (and possibly others) wouldn’t be possible in OH 2.3.
Anyway I would suggest adding somewhere at top of the quick start guide point like “Make sure you are running OpenHAB snapshot build 1318 (or newer) or OpenHAB milestone build 2 (or newer).” (dont know if milestone version is right) since “inviduals” like me may miss info from the main readme file
All of your image links give me 404s. (you can paste them right into the forum). The error must have been from one of the ESH imports.
It’s very helpful getting feedback from people getting started up on JSR223-Jython, with fresh eyes on the docs. Keep it coming, and thank you! I’ll update the readme in the open PR, which will hopefully be merged this weekend. Also, don’t hesitate to make corrections yourself and submit a pull request, you can do it through your browser… no IDE required!