Greetings all, to everyone, especially Kai, thank you for your tireless efforts on OH! I’m in the process of upgrading to OH4 now from 3. The question I’m about to ask may end up needing to be moved, as it regards jsr233/jython and the helper libraries and their compatibility with OH4.
After installing OH4.0.0-SNAPSHOT (I couldn’t figure out where to download M3… the download page says M3, but links you to the SNAPSHOT, but it seems stable enough…) I started slowly firing up the system, adding my bindings, items, etc. No issues yet. When I copied the “helper” libraries over, it began processing and loading them all. It actually went very smoothly except for one error that I have noticed so far.
The conf\automation\jsr223\python\core\components\100_DirectoryTrigger.py
file threw an error while loading.
This is the offending block of imports:
try:
from org.openhab.core.service import AbstractWatchService
except:
from org.eclipse.smarthome.core.service import AbstractWatchService
Basically, OH4 no longer has ‘AbstractWatchService’, so it caught that error, and then since this is not OH2.5 there is no longer ‘eclipse.smarthome’ and an unhandled error was generated. This isn’t a big deal, but I like things to work, so I started looking around in the binaries, and indeed could not find a ‘AbstractWatchService’ but could find a ‘WatchService’, so i adjusted the block of code to read:
try:
from org.openhab.core.service import WatchService as AbstractWatchService
except:
from org.eclipse.smarthome.core.service import AbstractWatchService
Now it loads just fine, and I decided I’d try to see if it works. After finding the example for Directory trigger in the community here, I set it to watch the \conf\scripts folder, and to trigger on ‘ENTRY_CREATE’, ie when a file is created in the directory. When I add a file to the directory it clearly sees the ENTRY_CREATE event and starts processing, but instead of causing an OpenHAB event, it throws an error:
Detected invalid event (hash must not be null for CREATE/MODIFY): DirectoryChangeEvent{eventType=CREATE, isDirectory=false, path=C:\OpenHAB\conf\scripts\New Microsoft Excel Worksheet.xlsx, count=1, rootPath=C:\OpenHAB\conf, hash=(null)}
It seems like it’s so close. I’m wondering if this has to do with certain arguments the “WatchService” is looking for vs. what the “AbstractWatchService” Sends. Anyways, I can do further testing or send other data if needed.
If anyone has any news on if there are updated jython scripting helper libraries in the works for OH4, please let me know.