How to Setup Jython

If this is not the case, then tell me which option is better? What to strive for? There is a lot of discussion, for example for me, with a lack of understanding of the English language (only google translator), sometimes it is very difficult to understand the subtleties, as well as to formulate a question so that they would understand me correctly.
Question: for OpenHAB3, which way of writing the rules is preferable? Considering that for me, only the file option is considered.
PS In no case, I did not want to offend anyone, I respect any work done and any feedback and help from any member of the community, my problem remains one, Google translator does not clearly express my thoughts and some people can understand them differently.
Thanks!

Update!
I would like to add on this topic. Of all the topics in the openHAB community that I follow, in my opinion, one of the best in terms of support!
Firstly, the entry into the topic is very well documented, secondly, the instant support of the author, in the main topic, in the newly created ones! We have to admit that not many topics are supported as well.

2 Likes

I think you are not getting the point here. He claims it is my fault that Jython support for OH3 is missing, which is completely untrue. Instead, there has never been a PR for that and we are waiting since months for one. So who is forcing what on whom?

Btw, this is not about @5iver and me. It is about how the community can collaborate. PR reviews in openhab-addons work without me as there are other maintainers as well. Likewise, if Jython-support is such an important feature for many, it should not rely on a single person. So if @5iver does not have the time or will to work on it, it should be possible for somebody else to take Add JythonScriptEngineFactory by 5iver Ā· Pull Request #7208 Ā· openhab/openhab-addons Ā· GitHub and make a mergeable PR for OH3 out of it. My question was therefore rather if he is working on it or if heā€™d want support from others (and I offered my help on that already).

5 Likes

Actually I got the impression scripting using JSR233 would be the future of rule-programming (vs. specifying rules somewhere) in openHAB. Your statement doesnā€™t sound like this and I am probably wrong? Is there a longer term / strategic direction where openHAB will go? I invested heavily in migrating from DSL to Jython for four reasons: #1 I had plenty of performance issues using DSL for calculating complex algorithms; #2 I found DSL not well designed when it comes to parallel processing (frequently occurring for rules with multiple triggers); #3 I prefer to use some mainstream language and #4 I thought it is what openHAB is heading to. Iā€™m happy with OH and Jython now.

2 Likes

JSR223 scripting is not only about jython, you can also use Javascript, groovy and possibly other languages. I myself use Javascript, which is already available.

1 Like

Exactly - the idea was to have those languages side-by-side so that users can choose the one they know/prefer. JS and Groovy are imho even more natural choices on a JVM, especially as there are unanswered concerns about the future support of Jython on a JVM. It would thus be imho foolish to make openHABā€™s future 100% dependent on that.

3 Likes

You mean like openHAB releases rely on you? :wink:

Ih the 2 posts in this thread you never once offered to help. You therefore came across as condescending & dictatorial to Scott & I as Americans.

Sorry for misinterpreting your intentions.

We are living on one world. Letā€™s solve problems together not with political statements.

3 Likes

It was meant as more cultural differences, not political.

1 Like

Right, since they do not rely on me. I am currently doing this work (and a million other things), but if there is a period in the future where I am busy with other projects and wonā€™t spend a minute for openHAB anymore, you can rest assured that others are able to do the releases as well and openHAB can further evolve.

I wrote: ā€œIā€™m thus very happy to see a PR with the migrated code (and adapted to the naming convention) and will do my best to very quickly help reviewing and merging it.ā€

I am sorry if this wasnā€™t perceived as a friendly, helping, collaborating and constructive statement, but as ā€œcondescending & dictatorialā€. This might then indeed be a lack of my skills in bridging cultural differences.

That was meant as humorous since you mentioned spreading out the releases to keep you busy.

That is not offering assistance writing the PR. @5iver responded he is busy mow with other things.

He has offered to assist somebody else from the community to write the PR. If nobody else wants to do that it is not Scottā€™s fault.

1 Like

We can also help with porting the PR to OH3 and see how well that works. But it can be perceived as a hostile take over. :wink:

Thank you. I think @5iver is a little overworked currently.

Sorry, being stressed it isnā€™t easy to identify humor these days - thanks for trying :wink: .

Yes, that was exactly what I thought and why I actually asked him whether he wants to do it himself (and might already have started) or if he is ok when somebody else takes it over.

If we now agree that his statements can be taken that he is fine with it, that sounds good.

1 Like

Perhaps you or @wborn should PM him to ask. Do not take my opinion as fact.

1 Like

The Jython and helper library add-ons have been complete for a long time, with the exception of incorporating the changes needed to move to an automation repository and a response to the namespaces that I had suggested. As I stated aboveā€¦

ā€¦ these are the things that I need decisively answered for me to be able to resubmit the add-ons:

  1. We agreed back in March to move everything but the rule engine to an automation repository, but this has not yet been created. When will this be created so that I can submit the add-ons there? Or have you changed your mind?

This discussion has gotten WAY off topic from what I had originally presented. My intention was to discuss creating a repository that would hold everything related to automation, where the maintainer(s) could focus specifically on automation. I feel this is very much needed for openHAB to evolve. You and @wborn preferred to keep the rule engines in OHC, so the scope of the discussion turned to the creation of a repository for automation, but with the exception of the current rule engine. An openHAB repository has not yet been created for this purpose.

  1. Iā€™ve waited for a response to my suggested namespaces since July, copied below. Unless I hear otherwise, I will just incorporate them into the Jython and helper library add-ons as I had suggested.

There are many more ScriptEngineFactory add-ons to submit, possibly some more helper library add-ons, but I would much rather work on a scripting API than helper libraries for each scripting language, and there are many community helper libraries that could be made into add-ons. Putting them all into this namespace will be ugly and difficult to manage, as I pointed out in openhab/openhab-core#1319 (comment). However, I will accept whatever namespace you force me to use in order to move this PR forward and to finally get it merged into 2.5.x. I suggest then to just take out the separators from the proposal I made three months agoā€¦

org.openhab.automation.scriptenginefactoryjython
org.openhab.automation.helperlibrariesjython
org.openhab.automation.helperlibrariesjythonareatriggersandactions

  1. While we are at itā€¦ the helper library add-on has not been reviewed. Other than the above changes, are there any other changes that will be required for it to be merged? At one point you had said that they needed to be included in the Jython add-on, which is a bad idea. The two add-ons are equally important.

How is there any question about whether I would continue work on my add-ons?! I will not make any commitments for M2, since I am unaware of any firm schedule for its release or when my questions will be answered, but Iā€™m not going to stop working on them.

Great ideaā€¦ show the community how well antagonizing disgruntled contributors with snide comments motivates them!

Sure wouldā€¦ just like the Groovy add-on was.

I never offered to assist somebody else to write the PR. Where did that come from?

I do not know which of my statements you are referring to or where you got the impression that I was not able to work on my add-ons. I am absolutely capable of migrating my work to OH3. I will not make any commitments for M2, since I do not know when my questions will be answered, but Iā€™m not going to stop working on them. Yes, my time is limited, but this there is very little left to do.

3 Likes

I must have misinterpreted this. Sorry.

I realize now I was wrong.

1 Like

I want to move on from the DSL rules so I started to learn python and I tried to setup Jython.
Iā€™m pretty sure that I did all the steps from https://openhab-scripters.github.io/openhab-helper-libraries/Getting%20Started/Installation.html

After starting openhab service I see this in karaf log

    20:19:49.087 [DEBUG] [ript.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language 'py' with identifier: file:/etc/openhab2/automation/jsr223/python/core/000_startup.py
    20:19:49.234 [WARN ] [jython.Startup                       ] - 

    *******************************************************************************
    Jython version:       2.7.0.final
    Operating system:     Linux
    OS Version:           5.4.51-v7+
    Java vendor:          Azul Systems, Inc.
    Java VM name:         OpenJDK Client VM
    Java runtime name:    OpenJDK Runtime Environment
    Java runtime version: 1.8.0_152-b76
    sys.path:             /etc/openhab2/automation/lib/python
                          /etc/openhab2/automation/jython/Lib
                          /etc/openhab2/automation/jython/jython-standalone-2.7.0.jar/Lib
                          __classpath__
                          __pyclasspath__/
    *******************************************************************************

And some error afterwards (I removed a part of the log to make it more readable)

    Loading script 'python/core/components/100_DirectoryTrigger.py'
    Added ScriptEngine for language 'py' with identifier: file:/etc/openhab2/automation/jsr223/python/core/components/100_DirectoryTrigger.py
    Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/python/core/components/100_DirectoryTrigger.py': ImportError: No module named configuration in <script> at line number 20
    Loading script 'python/core/components/100_OsgiEventTrigger.py'
    Added ScriptEngine for language 'py' with identifier: file:/etc/openhab2/automation/jsr223/python/core/components/100_OsgiEventTrigger.py
    Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/python/core/components/100_OsgiEventTrigger.py': ImportError: No module named configuration in <script> at line number 10
    Loading script 'python/core/components/100_StartupTrigger.py'
    Added ScriptEngine for language 'py' with identifier: file:/etc/openhab2/automation/jsr223/python/core/components/100_StartupTrigger.py
    Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/python/core/components/100_StartupTrigger.py': ImportError: No module named configuration in <script> at line number 10
    Loading script 'python/core/components/200_JythonBindingInfoProvider.py'
    Added ScriptEngine for language 'py' with identifier: file:/etc/openhab2/automation/jsr223/python/core/components/200_JythonBindingInfoProvider.py      
    Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/python/core/components/200_JythonBindingInfoProvider.py': ImportError: No module named configuration in <script> at line number 8
    Loading script 'python/core/components/200_JythonExtensionProvider.py'
    Added ScriptEngine for language 'py' with identifier: file:/etc/openhab2/automation/jsr223/python/core/components/200_JythonExtensionProvider.py
    Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/python/core/components/200_JythonExtensionProvider.py': ImportError: No module named configuration in <script> at line number 10
    Loading script 'python/core/components/200_JythonItemChannelLinkProvider.py'
    Added ScriptEngine for language 'py' with identifier: file:/etc/openhab2/automation/jsr223/python/core/components/200_JythonItemChannelLinkProvider.py
    Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/python/core/components/200_JythonItemChannelLinkProvider.py': ImportError: No module named configuration in <script> at line number 9
    Loading script 'python/core/components/200_JythonItemProvider.py'
    Added ScriptEngine for language 'py' with identifier: file:/etc/openhab2/automation/jsr223/python/core/components/200_JythonItemProvider.py
    Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/python/core/components/200_JythonItemProvider.py': ImportError: No module named configuration in <script> at line number 9
    Loading script 'python/core/components/200_JythonThingProvider.py'
    Added ScriptEngine for language 'py' with identifier: file:/etc/openhab2/automation/jsr223/python/core/components/200_JythonThingProvider.py
    Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/python/core/components/200_JythonThingProvider.py': ImportError: No module named configuration in <script> at line number 8
    Loading script 'python/core/components/200_JythonThingTypeProvider.py'
    Added ScriptEngine for language 'py' with identifier: file:/etc/openhab2/automation/jsr223/python/core/components/200_JythonThingTypeProvider.py        
    Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/python/core/components/200_JythonThingTypeProvider.py': ImportError: No module named configuration in <script> at line number 8
    Loading script 'python/core/components/200_JythonTransform.py'
    Added ScriptEngine for language 'py' with identifier: file:/etc/openhab2/automation/jsr223/python/core/components/200_JythonTransform.py
    Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/python/core/components/200_JythonTransform.py': ImportError: No module named configuration in <script> at line number 10

I also continued and placed the hello_world.py script in /automation/jsr223/python/personal/ and another error

    Loading script 'python/personal/hello_world.py'
    Added ScriptEngine for language 'py' with identifier: file:/etc/openhab2/automation/jsr223/python/personal/hello_world.py
    Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/python/personal/hello_world.py': ImportError: No module named configuration in <script> at line number 1

Iā€™m running openhab 2.5.9 on a RPi3 with Debian 10 (not openhabian).

Any ideas?

Looks like you missed #8ā€¦

1 Like

Iā€™m so stupid, I renamed the file in the extracted folder not on the RPi.
Thanks!

1 Like

Itā€™s a small step that gets missed often.

1 Like