[beta testers wanted!] Jython addon w/ helper libraries (requires OH 2.5.x)

No need for that. To reload a module, you need to import it first, before it can be reloaded…

import configuration
reload(configuration)
from configuration import my_module

Is this not clear in the docs? If not I’ll try to do better explaining how to reload a module.

Yes it’s clear in the docs, no need to change that. Albeit it’s pretty unintuitive that you need to use import twice, I had removed the first import which is what ultimately caused my issue.

1 Like

Not sure if it is addon related or just my config but I tried to use the items.<itemname> shortcut - instead of `ir.getItem(“itemname”).state - but it fails:

[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/personal/test.py'
[ERROR] [org.openhab.automation.jython       ] - Traceback (most recent call last):
  File "/openhab/userdata/cache/org.eclipse.osgi/203/1/bundleFile/Lib/core/log.py", line 51, in wrapper
    return function(*args, **kwargs)
  File "/openhab/userdata/cache/org.eclipse.osgi/203/1/bundleFile/Lib/core/rules.py", line 108, in execute
    self.callback(inputs.get('event'))
  File "<script>", line 18, in testRule
AttributeError: 'org.openhab.core.automation.module.script.internal' object has no attribute 'Test_Item'

For this test rule:

from core.rules import rule
from core.triggers import when
from core.log import logging
import configuration
reload(configuration)
from configuration import LOG_PREFIX

@rule("Test Rule")
@when("System started")
def testRule(event):
    testRule.log = logging.getLogger("{}.testRule".format(LOG_PREFIX))
    if items.Test_Item == ON:
        testRule.log.info("Test_Item is ON")        
    else:
        testRule.log.info("Test_Item is not ON (probably OFF)")

and this item:

Switch  Test_Item

Using your code, I got the same error. I than swapped out the Item for one that exists on my system and it worked fine. There’s some cleanup you can do in this code too. Since you are using the rule decorator, the function will have a log attribute added to it already. I also added another way of getting an Items state, so if it errors there, you need to check your Item definition.

from core.rules import rule
from core.triggers import when

@rule("Test Rule")
@when("System started")
def testRule(event):
    if items["Test_Item"] == ON:
        testRule.log.info("Test_Item is ON")        
    else:
        testRule.log.info("Test_Item is not ON (probably OFF)")
    if items.Test_Item == ON:
        testRule.log.info("Test_Item is ON")        
    else:
        testRule.log.info("Test_Item is not ON (probably OFF)")

Thanks Scott, for your quick reply.

This works:

    if items["Test_Item"] == ON:

This doesn’t:

    if items.Test_Item == ON:

I’ll turn on debug logging to see what’s going on.

That’s odd. How did you create the Item?

*.items file.
I’ll do some more test…

I was hoping that I could start testing the beta. Until now I have downloaded Core and Community python code from the repo. As I understand it, this will now not be needed anymore, as this is included in the jar. Is this correct?
If it is correct, how can I then handle the situation where I have some changes to the Community contribution that I would like to use instead of the code shipped with the JAR?

I am a little in doubt how this would work? As an example I have added something to ideAlarm and is now waiting for the code being merged. Obviously this isn’t done day to day, as we all use our sparetime for this. But my question is, can I use the newest code while waiting for the contribution being merged?

BTW. I think the “new” rule engine is a great enhancement of openHAB, the great work is appreciated :slight_smile:

Yes, this is correct for now. However, I may split the helper libraries out into a separate bundle. I’m still undecided on this though.

Using the bundle, you can test changes to modules in the core or community packages by copying the modules into the personal package, which is the current recommendation in the documentation. After testing, copy them into the community package in your local repository and make your commit.

Although, I personally prefer to use a manual Jython install with symlinks to my local repository when developing the libraries.

I have contributed only a small fraction of the whole, but thank you! Knowing someone appreciates the effort means a lot… and hearing it sure brings out the sunshine! :sun_with_face:

I had the beta installed for several weeks now and migrated all my rules to Jython. Everything has been fine. Today, I have updated openHAB from 2.5.1 stable to 2.5.2 stable using the openHABian Configuration tool. The update ran through, but openHAB is not working correctly any more. In the openhab2.log I get this message when starting:

2020-02-20 18:22:56.313 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/usr/share/openhab2/addons/org.openhab.core.automation.module.script.scriptenginefactory.jython-2.5.0-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.core.automation.module.script.scriptenginefactory.jython [204]
  Unresolved requirement: Import-Package: org.openhab.core.automation.module.script; version="[2.5.0,3.0.0)"

        at org.eclipse.osgi.container.Module.start(Module.java:444) ~[org.eclipse.osgi-3.12.100.jar:?]
        at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:383) ~[org.eclipse.osgi-3.12.100.jar:?]
        at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1260) [bundleFile:3.6.4]
        at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1233) [bundleFile:3.6.4]
        at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:520) [bundleFile:3.6.4]
        at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365) [bundleFile:3.6.4]
        at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316) [bundleFile:3.6.4]

Afterwards, openHAB is dead, i.e. not responding on http://openhabian:8080 or when starting the Karaf console using

[19:02:40] openhabian@openhab:~$ ssh -p 8101 openhab@localhost

ssh: connect to host localhost port 8101: Connection refused

I have removed the Jython helper jar from the add-ons share to allow openHAB to start up, but the behavior doesn’t change (except the log is completely dead now, even without the exception mentioned above).

Interesting enough, the openhab2 service claims it has been started and everything is fine. :frowning:

[19:02:45] openhabian@openhab:~$ sudo /etc/init.d/openhab2 status
● openhab2.service - openHAB 2 - empowering the smart home
   Loaded: loaded (/usr/lib/systemd/system/openhab2.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2020-02-20 18:57:50 CET; 8min ago
     Docs: https://www.openhab.org/docs/
           https://community.openhab.org
 Main PID: 4067 (java)
    Tasks: 35 (limit: 4915)
   Memory: 135.0M
   CGroup: /system.slice/openhab2.service
           └─4067 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab.runtime=/usr/share/openhab2/runtime -Dopenhab.userdata=/var/lib/openhab2 -Dopenhab.logdir=/var/log/openhab2 -Dfelix.cm.dir=/var/lib/openhab2/conf…

Feb 20 18:57:50 openhab systemd[1]: Started openHAB 2 - empowering the smart home.

Any clue how to trouble shoot this? Anyone with the same issue?

Thanks for your help.

I have not upgraded to 2.5.2 yet, but will take a look tonight. openHABian uses the official update script, so the cache would have been cleared. I’ve had issues with the cache being cleared and needing to restart a second time after things have settled down. Although, clearing the cache another time may help things too. The error means the bundle can’t find one of the other bundles in the new rule engine. Check to make sure it is installed. I don’t see this as being an issue with the bundle, but we’ll see if anyone else runs into it. Thank you for reporting!

This has been an issue with the openHAB update process, not the Jython beta. After clearing the cache, the openHAB system started up again. Initially I did not even get PaperUI from openhabian:8080, but after rebooting and restarting the service several times it slowly recovered. I have re-added the automation jar now, and things work again. Btw, how to check the jar is the latest version?

2 Likes

Glad you are up and running again!

The current version is 2.5.0.202001221001, which you can find in the /META-INF/MANIFEST.MF file inside the bundle or by running the following in the console…

list -s | grep jython

The only change was to append the python.path to any existing python.path, so that it was not being overwritten. This allows you to specify directories that hold custom or third-party libraries located outside of the OH directory structure.

Just fyi, GraalVM 20.0 has been released with improved Jython and JS support.
Don’t wanna spoil this party and Scott’s efforts here, of course.

I performed the steps below to verify/reproduce the issue (of not being able to resolve items.itemname):

  1. Deploy a new VM (in Azure) running Debian 10.
  2. Deploy Docker in the VM.
  3. Deploy the official 2.5.2 Docker image.
  4. Stop OH (after it completed initial startup).
  5. Copy the scripts from the Helper Library to ${OPENHAB_CONF}/automation/jsr223/python/core.
  6. Create ${OPENHAB_CONF}/automation/lib/python/configuration.py.
  7. Create ${OPENHAB_CONF}/automation/jsr223/python/personal/test.py` (see below).
  8. Copy beta bundle (Jan 22 version) to ${OPENHAB_HOME}/addons.
  9. Start OH.

The test rule:

from core.rules import rule
from core.triggers import when
from core.items import add_item

@rule("Test Rule")
@when("System started")
def testRule(event):
    if ir.getItems("testitem") == []:
        add_item("testitem", item_type="Switch")
        testRule.log.info("0. Created Test switch Item")

    testRule.log.info("1. Test switch is {}".format(ir.getItem("testitem").state))
    testRule.log.info("2. Test switch is {}".format(items["testitem"]))
    testRule.log.info("3. Test switch is {}".format(items.testitem))

The relevant part of the logfile:

[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/core/000_startup_delay.py'
[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/core/components/100_DirectoryTrigger.py'
[INFO ] [on.jython.core.DirectoryEventTrigger] - TriggerHandler added [jsr223.DirectoryTrigger]
[INFO ] [on.jython.core.DirectoryEventTrigger] - TriggerType added [jsr223.DirectoryTrigger]
[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/core/components/100_OsgiEventTrigger.py'
[ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/openhab/conf/automation/jsr223/python/core/components/100_OsgiEventTrigger.py': ImportError: cannot import name osgi_triggers in <script> at line number 17
[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/core/components/100_StartupTrigger.py'
[INFO ] [utomation.jython.core.StartupTrigger] - TriggerHandler added [jsr223.StartupTrigger]
[INFO ] [utomation.jython.core.StartupTrigger] - TriggerType added [jsr223.StartupTrigger]
[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/core/components/200_JythonBindingInfoProvider.py'
[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/core/components/200_JythonExtensionProvider.py'
[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/core/components/200_JythonItemChannelLinkProvider.py'
[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/core/components/200_JythonItemProvider.py'
[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/core/components/200_JythonThingProvider.py'
[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/core/components/200_JythonThingTypeProvider.py'
[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/core/components/200_JythonTransform.py'
[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/personal/test.py'
[INFO ] [.openhab.automation.jython.Test Rule] - 0. Created Test switch Item
[INFO ] [.openhab.automation.jython.Test Rule] - 1. Test switch is NULL
[INFO ] [.openhab.automation.jython.Test Rule] - 2. Test switch is NULL
[ERROR] [org.openhab.automation.jython       ] - Traceback (most recent call last):
  File "/openhab/userdata/cache/org.eclipse.osgi/210/0/bundleFile/Lib/core/log.py", line 51, in wrapper
    return function(*args, **kwargs)
  File "/openhab/userdata/cache/org.eclipse.osgi/210/0/bundleFile/Lib/core/rules.py", line 108, in execute
    self.callback(inputs.get('event'))
  File "<script>", line 14, in testRule
AttributeError: 'org.openhab.core.automation.module.script.internal' object has no attribute 'testitem'

What step am I missing?

What is this the January 22 Helper Library?

I haven’t tried to reproduce this yet, but I think I see what is causing this. Your script is loading core before there are any Items, so items does not exist and core.__init__.py does not add the attribute. Try restarting OH again or reloading the core package.

Sorry, I mixed up the dates of the HL and the bundle (which is from Jan 22). To clarify, I DL’ed the HL again last night and used that version.
Updated the original post as well.

Stopped OH, cleared tmp and cache and restarted OH. Result: :no_mouth:

[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/core/000_startup_delay.py'
[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/core/components/100_DirectoryTrigger.py'
[INFO ] [on.jython.core.DirectoryEventTrigger] - TriggerHandler added [jsr223.DirectoryTrigger]
[INFO ] [on.jython.core.DirectoryEventTrigger] - TriggerType added [jsr223.DirectoryTrigger]
[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/core/components/100_OsgiEventTrigger.py'
[ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/openhab/conf/automation/jsr223/python/core/components/100_OsgiEventTrigger.py': ImportError: cannot import name osgi_triggers in <script> at line number 17
[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/core/components/100_StartupTrigger.py'
[INFO ] [utomation.jython.core.StartupTrigger] - TriggerHandler added [jsr223.StartupTrigger]
[INFO ] [utomation.jython.core.StartupTrigger] - TriggerType added [jsr223.StartupTrigger]
[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/core/components/200_JythonBindingInfoProvider.py'
[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/core/components/200_JythonExtensionProvider.py'
[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/core/components/200_JythonItemChannelLinkProvider.py'
[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/core/components/200_JythonItemProvider.py'
[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/core/components/200_JythonThingProvider.py'
[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/core/components/200_JythonThingTypeProvider.py'
[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/core/components/200_JythonTransform.py'
[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/personal/test.py'
[INFO ] [.openhab.automation.jython.Test Rule] - 1. Test switch is NULL
[INFO ] [.openhab.automation.jython.Test Rule] - 2. Test switch is NULL
[ERROR] [org.openhab.automation.jython       ] - Traceback (most recent call last):
  File "/openhab/userdata/cache/org.eclipse.osgi/203/0/bundleFile/Lib/core/log.py", line 51, in wrapper
    return function(*args, **kwargs)
  File "/openhab/userdata/cache/org.eclipse.osgi/203/0/bundleFile/Lib/core/rules.py", line 108, in execute
    self.callback(inputs.get('event'))
  File "<script>", line 14, in testRule
AttributeError: 'org.openhab.core.automation.module.script.internal' object has no attribute 'testitem'

What if you just restart OH without clearing the cache? Also, put the logging of jsr223 and org.openhab.core.automation into debug.

[DEBUG] [.AutomationResourceBundlesEventQueue] - Process bundle event 2, for automation bundle 'org.openhab.core.automation'
[DEBUG] [.AutomationResourceBundlesEventQueue] - Process bundle event 32, for automation bundle 'org.openhab.core.automation.module.script.rulesupport'
[DEBUG] [vider.AbstractResourceBundleProvider] - Parse rules from bundle 'org.openhab.core.automation'
[DEBUG] [vider.AbstractResourceBundleProvider] - Parse rules from bundle 'org.openhab.core.automation.module.script.rulesupport'
[DEBUG] [e.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added CoreModuleHandlerFactory
[DEBUG] [e.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added EphemerisModuleHandlerFactory
[DEBUG] [e.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added TimerModuleHandlerFactory
[DEBUG] [e.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added AnnotatedActionModuleTypeProvider
[DEBUG] [e.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added AnnotatedThingActionModuleTypeProvider
[DEBUG] [e.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added MediaModuleHandlerFactory
[DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Initialized a custom ScriptEngineFactory for jython (2.7.0): supports python (2.7) with file extensions [py], names [python, jython], and mimetypes [text/python, application/python, text/x-python, application/x-python]
[DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Initialized a generic ScriptEngineFactory for Oracle Nashorn (1.8.0_232-b18): supports ECMAScript (ECMA - 262 Edition 5.1) with file extensions [js], names [nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript], and mimetypes [application/javascript, application/ecmascript, text/javascript, text/ecmascript]
[DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Initialized a custom ScriptEngineFactory for Oracle Nashorn (1.8.0_232-b18): supports ECMAScript (ECMA - 262 Edition 5.1) with file extensions [js], names [nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript], and mimetypes [application/javascript, application/ecmascript, text/javascript, text/ecmascript]
[DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Removed JythonScriptEngineFactory
[DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Removed GenericScriptEngineFactory
[DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Removed NashornScriptEngineFactory
[DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Initialized a custom ScriptEngineFactory for jython (2.7.0): supports python (2.7) with file extensions [py], names [python, jython], and mimetypes [text/python, application/python, text/x-python, application/x-python]
[DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Initialized a generic ScriptEngineFactory for Oracle Nashorn (1.8.0_232-b18): supports ECMAScript (ECMA - 262 Edition 5.1) with file extensions [js], names [nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript], and mimetypes [application/javascript, application/ecmascript, text/javascript, text/ecmascript]
[DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Initialized a custom ScriptEngineFactory for Oracle Nashorn (1.8.0_232-b18): supports ECMAScript (ECMA - 262 Edition 5.1) with file extensions [js], names [nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript], and mimetypes [application/javascript, application/ecmascript, text/javascript, text/ecmascript]
[DEBUG] [e.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added ScriptModuleHandlerFactory
[DEBUG] [e.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added ScriptedCustomModuleHandlerFactory
[DEBUG] [e.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added ScriptedPrivateModuleHandlerFactory
[INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel
[INFO ] [ebuilder.internal.HomeBuilderServlet] - Started Home Builder at /homebuilder
[INFO ] [openhab.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui
[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/core/000_startup_delay.py'
[DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language 'py' with identifier: file:/openhab/conf/automation/jsr223/python/core/000_startup_delay.py
[INFO ] [jsr223.jython.core.startup_delay    ] - Checking for initialized context
[INFO ] [jsr223.jython.core.startup_delay    ] - Context initialized... waiting 30s before allowing scripts to load
[INFO ] [jsr223.jython.core.startup_delay    ] - Complete
[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/core/components/100_DirectoryTrigger.py'
[DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language 'py' with identifier: file:/openhab/conf/automation/jsr223/python/core/components/100_DirectoryTrigger.py
[INFO ] [on.jython.core.DirectoryEventTrigger] - TriggerHandler added [jsr223.DirectoryTrigger]
[INFO ] [on.jython.core.DirectoryEventTrigger] - TriggerType added [jsr223.DirectoryTrigger]
[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/core/components/100_OsgiEventTrigger.py'
[DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language 'py' with identifier: file:/openhab/conf/automation/jsr223/python/core/components/100_OsgiEventTrigger.py
[ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/openhab/conf/automation/jsr223/python/core/components/100_OsgiEventTrigger.py': ImportError: cannot import name osgi_triggers in <script> at line number 17
[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/core/components/100_StartupTrigger.py'
[DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language 'py' with identifier: file:/openhab/conf/automation/jsr223/python/core/components/100_StartupTrigger.py
[INFO ] [utomation.jython.core.StartupTrigger] - TriggerHandler added [jsr223.StartupTrigger]
[INFO ] [utomation.jython.core.StartupTrigger] - TriggerType added [jsr223.StartupTrigger]
[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/core/components/200_JythonBindingInfoProvider.py'
[DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language 'py' with identifier: file:/openhab/conf/automation/jsr223/python/core/components/200_JythonBindingInfoProvider.py
[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/core/components/200_JythonExtensionProvider.py'
[DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language 'py' with identifier: file:/openhab/conf/automation/jsr223/python/core/components/200_JythonExtensionProvider.py
[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/core/components/200_JythonItemChannelLinkProvider.py'
[DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language 'py' with identifier: file:/openhab/conf/automation/jsr223/python/core/components/200_JythonItemChannelLinkProvider.py
[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/core/components/200_JythonItemProvider.py'
[DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language 'py' with identifier: file:/openhab/conf/automation/jsr223/python/core/components/200_JythonItemProvider.py
[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/core/components/200_JythonThingProvider.py'
[DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language 'py' with identifier: file:/openhab/conf/automation/jsr223/python/core/components/200_JythonThingProvider.py
[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/core/components/200_JythonThingTypeProvider.py'
[DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language 'py' with identifier: file:/openhab/conf/automation/jsr223/python/core/components/200_JythonThingTypeProvider.py
[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/core/components/200_JythonTransform.py'
[DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language 'py' with identifier: file:/openhab/conf/automation/jsr223/python/core/components/200_JythonTransform.py
[INFO ] [me.core.service.AbstractWatchService] - Loading script 'python/personal/test.py'
[DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language 'py' with identifier: file:/openhab/conf/automation/jsr223/python/personal/test.py
[DEBUG] [e.automation.internal.RuleEngineImpl] - The trigger 'System_started_c164289e54b211eaac3439d00c62e8de_c28a0b0054b211eaadb239d00c62e8de' of rule '13f3edcc-9f41-4b94-ab23-555d7988e1c2' is triggered.
[INFO ] [.openhab.automation.jython.Test Rule] - 1. Test switch is NULL
[INFO ] [.openhab.automation.jython.Test Rule] - 2. Test switch is NULL
[ERROR] [org.openhab.automation.jython       ] - Traceback (most recent call last):
  File "/openhab/userdata/cache/org.eclipse.osgi/203/0/bundleFile/Lib/core/log.py", line 51, in wrapper
    return function(*args, **kwargs)
  File "/openhab/userdata/cache/org.eclipse.osgi/203/0/bundleFile/Lib/core/rules.py", line 108, in execute
    self.callback(inputs.get('event'))
  File "<script>", line 14, in testRule
AttributeError: 'org.openhab.core.automation.module.script.internal' object has no attribute 'testitem'

[DEBUG] [e.automation.internal.RuleEngineImpl] - The rule '13f3edcc-9f41-4b94-ab23-555d7988e1c2' is executed.

Makes no difference… :smirk:

1 Like

If you would, could you give testitem a state and restart OH?