However I already struggle to get jython onto my pi. I tried ap-get however this fails. Do I just need to download the jar file? and if so into which folder?
You can use the standalone jar (that’s what I use) or an install. They can be anywhere, but you need to configure the paths in EXTRA_JAVA_OPTS. I did this in my start.sh…
I don’t use lucid, but it has a lot of nice things in it to simplify the transition from the Rules DSL. I am also currently finishing up an update that will really simplify rule definition. Should be ready by this weekend.
Please let me know what your challenges are and I’ll work on getting the documentation cleaned up to address those areas. I already have some updates in here.
I cut a branch to keep the older (pre 2.3 build 1319) code archived, and these changes could be made to work with it. But there have been so many changes/improvements to the Automation API, that anyone using JSR223 should really be using a milestone build, at a minimum. The Rules DSL and JSR223 can definitely both be used simultaneously, and multiple languages can be used at the same time too.
Hello Tomibeck,
you are on the right track. In addition to the reply of @5iver, please also check the following wiki page. There you will also find generic examples for all three JSR223 implementations (JavaScript, Jython, Groovy).
EDIT: Alright, my browser cache was outdated… I still saw your initial question…
Okay I was able to install jython now trying to setup
As soona s i put the py files into the jsr223 fodler i get the following errors:
2018-10-05 19:03:05.078 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script '000_StartupTrigger.py'
2018-10-05 19:03:05.082 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error while creating ScriptEngine
java.lang.NullPointerException: null
at org.eclipse.smarthome.automation.module.script.internal.GenericScriptEngineFactory.scopeValues(GenericScriptEngineFactory.java:59) ~[?:?]
at org.eclipse.smarthome.automation.module.script.internal.ScriptEngineManagerImpl.createScriptEngine(ScriptEngineManagerImpl.java:88) ~[?:?]
at org.eclipse.smarthome.automation.module.script.rulesupport.internal.loader.ScriptFileWatcher.importFile(ScriptFileWatcher.java:164) ~[?:?]
at org.eclipse.smarthome.automation.module.script.rulesupport.internal.loader.ScriptFileWatcher.processWatchEvent(ScriptFileWatcher.java:135) ~[?:?]
at org.eclipse.smarthome.core.service.WatchQueueReader.lambda$3(WatchQueueReader.java:323) ~[?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
at java.lang.Thread.run(Thread.java:748) [?:?]
2018-10-05 19:03:05.106 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - could not load script as no engine is created
I’m not familiar with the error you are getting. Also, it looks like you are adding in one of the component scripts, and this particular one will not work yet. I’d leave them out until they are updated. Sorry… you are starting up just as everything is being shuffled. I’m almost getting to the documentation, which is already partially updated in the PR. I plan to push some more updates this weekend.
Are you using the lucid modules? These are definitely out of date, and I’m hoping @RRoe updates them after I get openhab2-Jython cleaned up.
Put in the modules but hold off on the components for now, and turn on debug logging for org.eclipse.smarthome.automation. Use the triggers.py from my PR. Then try a simple script to test it out. Start with the Raw ESH example, then grab the triggers.py, then extensions, then decorator. See if that all works for you. I haven’t tried with a full Jython install, but others have.
I’ve merged the PR, so the repo is updated and I could use some testers before I put together a post. It looks like the documentation needs to be reflowed to start people out at an entry level too.
I finally had the time to setup my spare RPI (openhabian image) and used your repo guide to install jython. I haven’t done more than a test script and it’s working but I get several errors when OH restarts.
Also, the jar file had to be placed in /usr/share/openhab2/runtime/lib/boot for the rules engine to start. Error was this: “ScriptEngine for py not available” is this b/c I’m using the openhabian image?
2018-10-08 11:36:30.213 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/000_components/000_DirectoryTrigger.py': ImportError: No module named openhab in <script> at line number 8
2018-10-08 11:36:30.218 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script '000_components/000_Esper.py'
2018-10-08 11:36:32.155 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/000_components/000_Esper.py': ImportError: No module named esper in <script> at line number 3
2018-10-08 11:36:32.160 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script '000_components/000_JythonBindingInfoProvider.py'
2018-10-08 11:36:32.307 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/000_components/000_JythonBindingInfoProvider.py': ImportError: No module named openhab in <script> at line number 3
2018-10-08 11:36:32.310 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script '000_components/000_JythonExtensionProvider.py'
2018-10-08 11:36:35.933 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/000_components/000_JythonExtensionProvider.py': ImportError: No module named openhab in <script> at line number 3
2018-10-08 11:36:35.938 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script '000_components/000_JythonItemProvider.py'
2018-10-08 11:36:36.094 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/000_components/000_JythonItemProvider.py': ImportError: No module named openhab in <script> at line number 3
2018-10-08 11:36:36.098 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script '000_components/000_JythonThingProvider.py'
2018-10-08 11:36:36.260 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/000_components/000_JythonThingProvider.py': ImportError: No module named openhab in <script> at line number 3
2018-10-08 11:36:36.263 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script '000_components/000_JythonThingTypeProvider.py'
2018-10-08 11:36:36.403 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/000_components/000_JythonThingTypeProvider.py': ImportError: No module named openhab in <script> at line number 3
2018-10-08 11:36:36.406 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script '000_components/000_JythonTransform.py'
2018-10-08 11:36:36.595 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/000_components/000_JythonTransform.py': ImportError: No module named openhab in <script> at line number 3
2018-10-08 11:36:36.599 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script '000_components/000_OsgiEventTrigger.py'
2018-10-08 11:36:39.340 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/000_components/000_OsgiEventTrigger.py': ImportError: No module named openhab in <script> at line number 10
2018-10-08 11:36:39.345 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script '000_components/000_StartupTrigger.py'
2018-10-08 11:36:39.486 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/000_components/000_StartupTrigger.py': ImportError: No module named openhab in <script> at line number 4
2018-10-08 11:36:39.489 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script '000_components/100_ExampleExtensionProvider.py'
2018-10-08 11:36:39.608 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/000_components/100_ExampleExtensionProvider.py': ImportError: No module named openhab in <script> at line number 1
Thanks for the repo guide and I hope to have more time for testing soon.
I see an issue… probably what’s causing your problem. Apt installs don’t have a conf directory. Try this for your EXTRA_JAVA_OPTS, and put the Jython jar back. You’ll need to restart again too.
Sorry I forgot to mention I didn’t use conf when adding to start.sh. I changed everything to match what you suggested above but only get error “ScriptEngine for py not available” and my test script no longer works. I also did not have a jython dir, like above(automation/jython), but created and placed a copy of the jar file. All permissions are good and also tried coping the jar file to /usr/share/openhab2/addons as well as /home/openhabian, restarting OH each time, but no luck.
Hmmm. If you followed the steps in the docs, then there’s something missing then. I’ll setup an apt install and test it out. Did you install the rule engine?
The modules go into /automation/lib/python/openhab"
The standalone jar goes into /automation/jython/
000_components goes into /automation/jsr223/, but you could skip these for now
I’m thinking I should just make a shell script…
Well, the errors mean the scripts can’t find the modules in /automation//lib/python/openhab/, and the ScriptEngine for py not available error means either the Experimental Rules engine is not installed, or Jython is not in the classpath.
Please post the script that works for you. I don’t see how it could have possible worked! I’m baffled.
What do you get from feature:list |grep ruleengine?
Should be…
openhab-misc-ruleengine │ 2.4.0.SNAPSHOT │ x │ Started │ openhab-addons-2.4.0-SNAPSHOT │ Rule Engine (Experimental)