Java Runtime Environment: _which java platform is used and what version_jython-standalone-2.7.0
openHAB version:
After upgrading from 2.4 to 2.5.5 Release build many issues most easily fixed from these forums thanks.
Last issues all seem to be the same the error is
2020-06-16 16:48:02.239 [INFO ] [me.core.service.AbstractWatchService] - Loading script ‘python/core/components/100_OsgiEventTrigger.py’
2020-06-16 16:48:02.712 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script ‘file:/etc/openhab2/automation/jsr223/python/core/components/100_OsgiEventTrigger.py’: ImportError: cannot import name bundle_context in at line number 8
They all seem similar here’s the beginning of the file
“”"
This rule trigger responds to events on the OSGi EventAdmin event bus.
“”"
import traceback
scriptExtension.importPreset(None)# fix for compatibility with Jython > 2.7.0
import core
import core.osgi.events
reload(core.osgi.events)
from core.osgi.events import OsgiEventAdmin, event_dict, OSGI_TRIGGERS
from core.log import logging, LOG_PREFIX
Thanks for the help.
I put the new helper libraries in because of all the errors after upgrading. Some rules are working and some seem to not be. Since the error doesn’t matter I’ll look into it some more and let you know.
Thanks again
I’m getting the same error on the triggers
Error during evaluation of script ‘file:/etc/openhab2/automation/jsr223/testswitch.py’: ImportError: cannot import name bundle_context in at line number 4
from org.slf4j import LoggerFactory
scriptExtension.importPreset(“RuleSupport”)
scriptExtension.importPreset(“RuleSimple”)
from core.triggers import ItemCommandTrigger, ItemStateChangeTrigger, ItemStateUpdateTrigger, CronTrigger
from core.jsr223.scope import events, itemRegistry
and none of the triggers are firing. This is from a simple test script to check things etc.
All the files under automation were updated from openhab on github yesterday.
Rules not using triggers on updating are running ok.
If this is a script, then don’t do this. events and itemRegistry are included in the default script scope. Modules are the only place you would need core.jsr223.scope.
I have not used extensions for a while. Why not use the when decorator? I merged some changes a few days ago, but I am not seeing this error. I have some more to merge though. I’ll do some more tests though…
even with a decorator I’d still need the imports correct. I did remove the trigger and the trigger is now firing.
I changed the import for audio from
from openhab.actions import Audio
to
from core.actions import Audio
It fails when going to play a sound.
I don’t want to waste your time is there documentation I missed on what the calls(Imports) where and are now.
Thanks again
I installed the jar in the addons and didn’t see anything in the logs. I do have other things installed thru the addons that are working.
Is there anything you’d like me to try?
Where is the core.osgi.events file located?
thanks…Greg
When I changed the file name to end in .org the jython addon now is working, but I’m still getting the same error as before with bundle_context.
So I can fix it if you tell where core.osgi.events is located.
Yes, but that wouldn’t prevent the loading of rules. I’m about the push the fix but it lured me into troubleshooting why the OsgiEventTrigger is not working!