git init
Initialized empty Git repository in /etc/openhab2/bwo/.git/
git remote add rich https://github.com/rkoshak/openhab-helper-libraries.git
git checkout -t rich/expire
fatal: 'rich/expire' is not a commit and a branch 'expire' cannot be created from it
I may give it a try later. I fetched OK but it looks the same as what I tried.
This line is the issue. from org.openhab.core.library.items import StringItem
Remove that line. I’m messing with this script today and that import isn’t used. It’s giving you an error because org.openhab.core is only present if you have compat1.x installed.
Please add a comment to the github and I’ll come back later today or tomorrow to take a look. I assumed that these have moved from org.eclipse as part of the great merge earlier this year. But if I’m indeed not using it there is no reason for the import to be there.
The current version of openhab still uses the eclipse namespace despite the merge.
I spent some time implementing and modify this script on the weekend. I will be making a PR on your branch when I have time. I added the live reload handling I think I suggested on the past as a hold over until we have item registry triggers. This required restructuring the expire rule and trigger generator to be dynamic.
OK, I got back to testing on a clean 2.5 Milestone 4 install. I removed the unneeded line and now get a different error.
2019-11-03 14:01:07.602 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/python/community/expire/expire.py': AttributeError: 'function' object has no attribute 'triggers' in <script> at line number 179
Yes that log is saying that the trigger generator function did not make any triggers (because no valid configurations exist). If you now have a valid configuration on an item you should remove the expire binding and restart openhab. When I first switched over to it the fact that expire binding was installed cause openhab to treat the expire metadata as not metadata so the script can’t see it until you restart.
The binding called Expire must be removed and then you must restart openhab. After that, this script called Expire will be able to see the expire metadata. If you have correctly configured expire metadata this script will monitor them and create timers as necessary.
Read the comments I put in the PR. Also thank you for testing it.
This log entry:
[DEBUG] [jsr223.jython.Expire Init ] - Unable to create Expire Reload rule, item 'expire_reload' does not exist
Is intentionally put under DEBUG not WARN because it is not really an error. The reload item is an optional function of this script because there is currently no way to listen for Item added, Item removed, or Item changed events. If you don’t have a reload item specified in configuration.py then the absence of the default item is not an error.