Sorry for the stupid question, but if this post requires most of the steps from the “standard install method” in the other link, then what is the difference? I see there is an additional jar - but is this supposed to be an easier way to install it, or add functionality? Or neither, were testing the jar itself in order to get this into PaperUI? Thanks!
[beta testers wanted!] Jython addon w/ helper libraries (requires OH 2.5.x)
Brilliant! I wish I had seen this before I tried doing a first-time installation.
Good thing I have a backup, which I can restore and start over.
All of the Python stuff is bundled into the jar file so you don’t have to download and install it from Jython directly. The command line flags to pass to openHAB to make it work is also done for you.
Easier way to install it.
Technically, you don’t need step 2 because openHAB is already shutdown in step 6 of the helper library installation.
And, shouldn’t steps 1 and 3 be moved to the helper library instructions? Step 1 would then become step 0, and step 3 would be inserted after step 6.
Also, I find this part of step 4 is confusing. Am I’m supposed to do this before step 5? Where do I copy these from?
Scott is referring to the
core directory in the helper libraries zip to be copied from
/conf/automation/jsr223/python/core. This is what should be copied in there:
├── 000_startup_delay.py └── components ├── 100_DirectoryTrigger.py ├── 100_OsgiEventTrigger.py ├── 100_StartupTrigger.py ├── 200_JythonBindingInfoProvider.py ├── 200_JythonExtensionProvider.py ├── 200_JythonItemChannelLinkProvider.py ├── 200_JythonItemProvider.py ├── 200_JythonThingProvider.py ├── 200_JythonThingTypeProvider.py └── 200_JythonTransform.py
Note that the script
100_OsgiEventTrigger.py currently gives an error in the log, but it is a known issue.
I really didn’t spend that much time analyzing the steps to deconflict the instructions like you have. I’m sure you are right, they weave together a little more tightly than the simple pattern I laid out.
Ok, thanks. But that already happens as a consequence of step 7 of the helper library instructions.
- …copy the contents of the
/Core/directory into your openHAB’s site configuration directory…
And, you can’t really skip step 7 because that creates the needed directory structure under
Therefore, before starting openHAB, should I delete the
automation/jsr223/python/personal directories that were created by step 7?
Yes, they do.
@5iver WDYT about creating a new set of instructions that describe how it do a first time install using the new
scriptenginefactory? If you want people to test this, they need a relatively straightforward way to do it. I usually can follow directions pretty well (despite what my wife might say to the contrary), but I had a hard time with this.
I can imagine. You kind of need to read between the lines and merge some steps with XOR logic.
But the instructions for copying the
core directory and step 7 overlap. With the addon most directories are not needed anymore in
conf/automation, just the one mentioned by @5iver , but it won’t hurt if they are still there.
Ok, thanks. I’ll hit the start button and see what happens.
Here are the steps that worked for me.
- Make sure you’re running OH 2.5.x (S1778) or newer
- The Next-Generation Rule Engine is still in development, so it is recommended to use the latest snapshot or milestone release of openHAB.
- Use the Karaf logging commands to enable debug logging for automation:
log:set DEBUG org.openhab.core.automation. Leave this on for setup and testing, but you may want to set to WARN when everything is setup. For older openHAB builds before the ESH reintegration (older than snapshot 1566 and 2.5M2), you will need to change this to
- Enable debug logging for jsr223:
log:set DEBUG jsr223. This is the default logger used in the examples and the helper libraries.
- Review the general openHAB Scripted Automation documentation and the language specific documentation found as links on that page.
- Install the Next-Generation Rule Engine add-on.
- Shut down openHAB and make a backup
Download the contents of this repository. Using the
openhabaccount, copy the contents of the
/Core/directory into your openHAB’s site configuration directory (Linux, Windows). This will create a directory structure as described in File Locations and will contain all of the Core files for each language, including the startup delay scripts that ensure openHAB has started completely before loading other scripts. If you do not plan to use all of the languages, you may want to remove the directories for them under
- There is a main configuration file for each scripting language’s helper libraries that must be renamed. For example, in
/automation/lib/python/, rename the file
configuration.py. These files can be used to secure personal information, so that they are not stored in files that may be shared with the community, or to store variables that are accesed by multiple scripts and/or modules, e.g. LOG_PREFIX.
- The ‘’/automation/lib/python/personal/__init.py.example`` file must be renamed to
__init__.py. If you modify it, take care not to overwrite the file during upgrades.
Download the bundle that matches your OH version to
- Copy the
/Script Examples/Python/hello_world.pyscript to
- 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 and should be deleted after installation has been verified.
- Ask questions on the openHAB forum and tag posts with
jsr223. Report issues here, but please don’t hesitate to update the documentation and code. Just like openHAB, this repository is community driven!
- Check out the First Steps page for what to do next.
Yes, the instructions need an update. Now that it’s been tested, I will be updating the instructions in the HL repo to use the bundle.
I guess my #1 and #2 can be merged into one step.
What’s that? LOL
There are a few more changes coming, including splitting out the helper libraries (maybe). I’ll be setting up a skeleton so that others can easily put together library bundles too. But I’ll get the instructions updated. I’m due for a big push.
Right now, I’m working on getting the component scripts to launch from inside the bundle, so that there will be nothing left to copy other than the configuration.py, but I may put that in as configuration for the library bundle (no file).
I’ve come across the problem that I failed to import a new setting from
configuration.py and found out that
'configuration$py.class' was not updated.
I think that’s the precompiled version and actually used rather than
configuration.py itself but never understood how that is supposed to work and when compilation takes place.
Can I manually start (re-)generation ?
Had a script already imported configuration.py before you added the new setting? If so, you’ll need to reload the configuration module or restart OH. The same will happen whenever you update a module. This is not something that is specific to the Jython bundle (same for manual install).
Yes but that’s not the point. I had deleted
'configuration$py.class'and it did not get regenerated.
Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/python/personal/battery.py': NameError: name 'configuration' is not defined in <script> at line number 9
Only inserting (unconditional)
import configuration finally did the trick.