JSR223 Helper Libraries/ Jython Support Install Guide - openHAB 2.5 (WIP)

This is a guide on how to install the JSR223 Helper Libraries / Jython Support. This is based on https://openhab-scripters.github.io/openhab-helper-libraries/Getting%20Started/Installation.html I’m a noob so of course those instructions weren’t enough for me :slight_smile: I hope this helps others. This guide is for a Raspberry Pi 3 & 4, running openHABian, & openHAB 2.5.1-2 (Release Build)

Those in the “know”, please keep me honest!

Guide:

  • I’ll update it based on any feedback or issues so you won’t have to read the entire post!

Install:

  • Install “Rule Engine (Experimental)” Binding in PaperUI
  • Stop Openhab service: sudo systemctl stop openhab2
  • Download https://github.com/openhab-scripters/openhab-helper-libraries/archive/master.zip
    ** Copy /Core/. -> /etc/openhab2/ (Should end up with /etc/openhab2/automation/…) [https://openhab-scripters.github.io/openhab-helper-libraries/Getting%20Started/File%20Locations.html DirStructure]
    ** Copy: /Script Examples/Python/hello_world.py script -> /automation/jsr223/python/personal/
  • Delete: /etc/openhab2/automation/jsr223/groovy & javascript
  • Delete: /etc/openhab2/automation/lib/groovy & javascript
  • Rename: /etc/openhab2/automation/lib/python/configuration.py.example -> configuration.py
  • Rename: /etc/openhab2/automation/lib/python/personal/__init.py.example -> __init.py
  • Modify EXTRA_JAVA_OPTS: (line ~38, update existing line - )
    sudo nano /etc/default/openhab2
    EXTRA_JAVA_OPTS="-Xms250m -Xmx350m -Xbootclasspath/a:/etc/openhab2/automation/jython/jython-standalone-2.7.0.jar -Dpython.home=/etc/openhab2/automation/jython -Dpython.path=/etc/openhab2/automation/lib/python"
    [CTRL+O] [ENTER] [CTRL+X] (Save, Exit nano)
  • Download the standalone Jython 2.7.0 jar or Download
    ** Copy jython-standalone-2.7.0.jar -> /etc/openhab2/automation/jython/
  • Clear cache (just in case)
    sudo rm -rf /var/lib/openhab2/cache/*
    sudo rm -rf /var/lib/openhab2/tmp/*
  • Restart: sudo reboot

Validate:

  • Enable JSR223 Logging:
    sudo openhab-cli console
    Default password: habopen
    log:set DEBUG org.openhab.core.automation (enable debug logging for automation
    log:set DEBUG jsr223 (Enable debug logging for jsr223)
  • Start openHAB and watch the logs for errors and the entries from the Hello World script.
  • This script will make a log entry every 10s.
  • Once validated, rename /automation/jsr223/python/personal/hello_world.py -> hello_world.py.example

Issues:

  • The 2nd time I did this I just copied/pasted the /etc/openhab2/automation/ folder from one workinginstance to another, but I kept getting errors like this:

2020-01-21 17:26:34.517 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script ‘file:/etc/openhab2/automation/jsr223/python/personal/hello_world.py’: ImportError: cannot import name LOG_PREFIX in at line number 5

  • I tried fixing permissions but this didn’t work:
    sudo chmod -R 777 /etc/openhab2/automation
  • I also tried restarting the Raspberry Pi, that did NOT work either.
  • I fixed this by deleting the /etc/openhab2/automation/ folder and doing the install manually step-by-step. Makes me think it was a permissions error…

I appreciate you taking the time to try and help people with the installation of Jython, but if you have questions or issues with the instructions in the helper library repo, then please submit an issue like the instructions tell you to do in step 14. There is a link at the bottom of every page. Reiterating them here is going to cause confusion, especially because your instructions are wrong.

Please remove these instructions. Anyone reading this, please ignore these (they are wrong) and follow the instructions in the HL repo.

This error is caused by not performing step 8 (setting up the configuration.py). You will also run into trouble running a manual install along with the beta Jython bundle.

Unfortunatley step 8 was in fact completed here so that’s not it. (I know this because I literally copied the /etc/openhab2/automation/ folder from a working openhab instance to another, along with adding the EXTRA_JAVA_OPTS, the Rule Engine, and bouncing openhab & I got those errors. I fixed the permissions, cleared the cache just in case, and same issue)

Appreciate the feedback - mind letting the community know what’s wrong with the steps? BTW I updated the title to include “(WIP)”. Thanks Scott.

The error you received was due to the configuration.py module not being importable. Either it did not exist, it was not renamed from configuration.py.example, or OH was running when it was copied or renamed and needed to be restarted… or configuration.py reloaded.

Just use the instructions in the helper library documentation, which will be updated soon to use the beta Jython bundle. If you find a problem or have questions, please submit an issue.

This is the third topic you have posted incorrect steps for installing Jython and this will cause confusion.

Mind letting the community know what steps here are incorrect?

As indicated in the other other thread, I posted the steps I did for troubleshooting purposes. I also commented there in regards to that. I’m unaware of a 3rd place I posted steps, let alone bad steps. Please forgive me.

Last time I made a suggestion about documentation I was greatly insulted and my ideas were not well received so I decided to stick to the community. That said, there are several issues with that link I based this on.

Improvement Suggestions to Existing Documentation (IMHO) (WIP):

  • Helper Libraries Installation is impossible to find unless you know where to link
  • JSR223 Scripting link doesnt link to the Helper Libraries Installation guide! (If it does, it isn’t obvious)
  • There is no version information in the Helper Libraries Installation so you have no idea if you just came across yet another irrelevant guide, or the “real deal”.
  • Helper Libraries Installation doesn’t indicate anything of such that it’s an official guide. This guide here comes across as just as official as that one, or maybe this one seems more official given the domain & location it’s in. (Why isn’t that guide on the openhab.org website in the official documentation?)
  • The standalone jython jar link gives a 404
  • Some of the steps aren’t clear to (me). Maybe minor or personal preference, but take #1 for example: this isn’t a step, its just a comment so why is it step 1? And Steps 2, 3, & 4 to my understanding aren’t needed either, rather for debugging & development steps.
  • I clearly put in my Guide this is for Raspberry Pi, which I understand is a very common HW choice. My guide is specific to that. So step 7 & 8, and all file locations are specified from root to help expedite the conf locations & such. Again, my goal was to make this a 1 stop shop to install this component and eliminate cross-research.
  • This guide is tagged with “Beginners”. Step 10 is a good example on what I mean: while I’m extremely proficient in Windows, I’m more of an amateur with Linux. So I spell out how to modify a file with nano, save it & exit.

Nonetheless, I greatly appreciate that guide because it did ultimately help me get this running. Those above are just my opinion, coming from an “openhab first-time technical user”. I will not take it personally if you ignore them.

Thanks Scott for your feedback.

UPDATE: I’m updating this post to clearly identify in bullets what I personally think is wrong with the current documentation. (Just constructive criticism) I know this is not the process (I’m supposed to create PR, etc), but given some of the remarks in this thread alone I’m sure you’ll understand why I’m not going to give “my worthless opinion” there - you guys might actually break me over in that arena!

Send @5iver a private message to discuss your issues and please do as he ask regarding the instruction removal.

I’m not trying to be mean or ugly and appreciate anyone that takes time to create a guide for helping others. I worked with Scott a year or so ago testing the install on a pi with openhabian. I learned a lot from that experience and he has worked very hard on this project so please help him by doing as he ask. If you want to make a contribution then message Scott, resolve the confusion and add it to the official doc’s.

More post in the community that are not correct results in more work for all that try and assist. One quality set of instructions that work beat the heck out of 20 attempts. :wink:

Thanks

1 Like

A moderator can certainly delete this thread if that’s the message “they” want to send the community, but I used this method and got it to work perfectly - so I’m asking what is wrong with my instructions: I’m being open here to input and will instantly update them as specific flaws are identified in my OP. I totally agree that there are a ton of bad guides, including guides in the official documentation, and that is the reason I put this together and shared with the community. It took me a day+ to get this working, but I strongly feel with my google searchable guide people will have this running in 30min or less.

Scott threw out a blanket statement indicating the guide is wrong - I’m waiting for feedback on what is wrong. As far as I know everything in this guide is correct and works. I tested the steps and tested the Jython scripting - all works as expected. All of the links work. This guide will be easy to find because its in the “community” section of the website. Remember, this community section is an informal area of the website. (We’re not talking about me modifying the formal documentation.) Also as I indicated, the Installation dox people are saying we need to use are not linked in the main JSR223 page which is the very first problem: its impossible to find. And are we next going to go through all of the community guides and ask users to delete them? Or is this common practice? Isnt the whole point of the “community” section of this website for users to post questions, guides, etc, without criticism? I did indicate in the title this works for ver 2.5. Once another version comes out it should be quickly clear its not relevant. Also, the point of having this guide in a thread is so that users can post comments, get help, etc. (You cant do that in a static webpage.)

Apologies, but if I give up here and delete this thread, then I’ll never post a helpful thread again. I will give up. That will hurt the community since this is all volunteer based - not just me not posting anymore, but the message we’ll send to existing users and prospective users reading these posts. Opensource SW is not just how awesome the product is, but equally the community support. I have found this the most difficult opensource community to work with thus far, and I just cant understand why given its such a cool sw package. I really hope I just had “bad luck”. This is NOT the way other communities work. You would NEVER see comments like this. And I don’t know why posting a guide requires me to explain myself or debate keeping the thread open. Can you imagine if every thread or guide got this kind of scrutiny? Mind-blowing. This section is supposed to be an informal posting area for the community. I have a ton of other “helpful” guides I planned to post as well…but maybe their not wanted? (At this point I’m thinking I’ll save myself the hassle and not post them, but the only people that will “lose” will be the users.) Is the message we want to send all users something like “posting threads and guides is frowned upon”? Or maybe some of these negative comments are NOT the consensus of the community as a whole? Hmmm…

Apologies again, but this just doesnt make any sense to me. I hope I’m not coming across as difficult or unfriendly, because if so that is absolutely not what I am; I just want to help the community and at this point I truly think I am with this Guide. So again, Moderator: feel free to delete if you think that’s the direction we need to go here…

Thanks to all the users, the community, the contributors, and the coders that make this such an awesome product!!

I’m not going to agree here. Kevin was able to find the instructions but they were not sufficient for him to get them to work. So, using the same approach I’ve used many times in the past he created a tutorial and ask for feed back before trying to submit a PR to the docs.

If this is the wrong approach, well then this wrong approach is how we got the OH 1.x to 2.x migration tutorial, type conversion section in the Rules docs, documentation for Emphemeris, and more.

If the existing docs were sufficient for a new user like Kevin this post would never have been created. Telling a user they are wrong and referring them back to the very same instructions that they weren’t able to use in the first place isn’t helpful either.

And if we were to go around demanding that every post that contains wrong information or duplicate information we’re going to have a pretty small forum.

But the sentiment also seems clear. No one should dare post anything about Python to this forum. I know it’s been made perfectly clear that I shouldn’t do so anymore either and I’m not going to.

This thread has pretty much guaranteed that Kevin won’t be offering any contributions to this project and one can only guess how many others will see it too and be scared away as well. I certainly wouldn’t have continued on had I received a similar reaction to my early clumsy attempts to help the community, many of which were equally as wrong and equally as duplicative.

2 Likes

FYI I updated Post 7 to be more concise.

The intent of the message was to work with Scott, let him know what can be done to improve the install for others, not discourage them in any way. If there’s an easier way for beginners to install and understand anything OH related I’m all for it. :+1:

I added my 2 cents b/c Scott mentioned a few things that were not correct. Regardless of who’s right or wrong, it’s best to hash it out private and post the correct info. IMHO, making a tutorial that contains argumentive post can discourage others from giving Jython a try.

@Kevin71246 I appreciate your contribution, please continue and hope you understand the reason for my post. Reach out to Scott, he’s a nice guy, the two of you can learn from each other and make a solid tutorial for everyone.

Thanks

3 Likes

I hope some one can implant this in Openhabian this documentation is very confusing. Is there a full command line tutorial?

This tutorial is using Windows and the command line?

There are Jython and helper library add-ons waiting to be merged, which will make installation as easy as any other add-on. Until then, use this…

The helper library documentation will be updated for using the add-ons, but they will have the steps for a manual installation too. The information in this topic is incorrect, incomplete, and outdated. Use this… https://openhab-scripters.github.io/openhab-helper-libraries/index.html. If there is something that you would like more detail on, open an issue in Github or submit a PR.

1 Like