Problem with unrecognized Python built-in function “isistance”
I am using openhabian 2.5.9-1 on a raspberry pi 3b.
I followed the OP to install this Jython addon and I managed to run the hello world example and some other scripts too. I am unable to use the built-in function isistance
as it gives the following error
2020-11-01 17:18:30.312 [ERROR] [Jython Hello World (cron decorators)] - Traceback (most recent call last):
File "/etc/openhab2/automation/lib/python/core/log.py", line 51, in wrapper
return fn(*args, **kwargs)
File "<script>", line 21, in hello_world_cron_decorators
NameError: global name 'isistance' is not defined
The script that I am trying to execute is the following
from core.rules import rule
from core.triggers import when
from core.log import logging, LOG_PREFIX, log_traceback
from threading import Timer
log = logging.getLogger("{}.HelloWorld".format(LOG_PREFIX))
@rule("Jython Hello World (cron decorators)", description="This is an example cron triggered rule using decorators", tags=["Test tag", "Hello World"])# description and tags are optional
@when("Time cron 0/30 * * * * ?")
def hello_world_cron_decorators(event):
dummy=Timer(10,lambda : log.info("Hello World,Timer elapsed")).start()
log.info("Hello World,Timer launched!")
if isistance(dummy,Timer):
log.info("it works")
else:
log.info("it does not work")
The scripts executes, launching the timer but it fails to execute the line containing isistance
.
I can’t figure out what I am doing wrong. Is it a problem with my installation?
The full log is
2020-11-01 17:18:30.254 [DEBUG] [e.automation.internal.RuleEngineImpl] - The trigger 'Time_cron_0_30_921296401c5d11eb992116ecc463c7ee_93ada89e1c5d11ebaf7516ecc463c7ee' of rule '9d3f8d9a-708a-47e4-9ef3-4d1a8410d293' is triggered.
2020-11-01 17:18:30.296 [INFO ] [jsr223.jython.HelloWorld ] - Hello World,Timer launched!
2020-11-01 17:18:30.312 [ERROR] [Jython Hello World (cron decorators)] - Traceback (most recent call last):
File "/etc/openhab2/automation/lib/python/core/log.py", line 51, in wrapper
return fn(*args, **kwargs)
File "<script>", line 21, in hello_world_cron_decorators
NameError: global name 'isistance' is not defined
2020-11-01 17:18:30.319 [ERROR] [e.automation.internal.RuleEngineImpl] - Failed to execute rule '9d3f8d9a-708a-47e4-9ef3-4d1a8410d293': Fail to execute action: 1
2020-11-01 17:18:30.323 [DEBUG] [e.automation.internal.RuleEngineImpl] -
java.lang.RuntimeException: Fail to execute action: 1
at org.openhab.core.automation.internal.RuleEngineImpl.executeActions(RuleEngineImpl.java:1197) ~[bundleFile:?]
at org.openhab.core.automation.internal.RuleEngineImpl.runRule(RuleEngineImpl.java:993) [bundleFile:?]
at org.openhab.core.automation.internal.TriggerHandlerCallbackImpl$TriggerData.run(TriggerHandlerCallbackImpl.java:91) [bundleFile:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_265]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_265]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_265]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_265]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_265]
Caused by: org.python.core.PyException
at org.python.core.Py.AttributeError(Py.java:205) ~[?:?]
at org.python.core.PyObject.noAttributeError(PyObject.java:1013) ~[?:?]
at org.python.core.PyObject.__getattr__(PyObject.java:1008) ~[?:?]
at core.rules$py.execute$6(/etc/openhab2/automation/lib/python/core/rules.py:110) ~[?:?]
at core.rules$py.call_function(/etc/openhab2/automation/lib/python/core/rules.py) ~[?:?]
at org.python.core.PyTableCode.call(PyTableCode.java:167) ~[?:?]
at org.python.core.PyBaseCode.call(PyBaseCode.java:307) ~[?:?]
at org.python.core.PyBaseCode.call(PyBaseCode.java:198) ~[?:?]
at org.python.core.PyFunction.__call__(PyFunction.java:482) ~[?:?]
at org.python.core.PyMethod.instancemethod___call__(PyMethod.java:237) ~[?:?]
at org.python.core.PyMethod.__call__(PyMethod.java:228) ~[?:?]
at org.python.core.PyMethod.__call__(PyMethod.java:218) ~[?:?]
at org.python.core.PyMethod.__call__(PyMethod.java:213) ~[?:?]
at org.python.core.PyObject._jcallexc(PyObject.java:3626) ~[?:?]
at org.python.core.PyObject._jcall(PyObject.java:3658) ~[?:?]
at org.python.proxies.core.rules$_FunctionRule$16.execute(Unknown Source) ~[?:?]
at org.openhab.core.automation.module.script.rulesupport.shared.simple.SimpleRuleActionHandlerDelegate.execute(SimpleRuleActionHandlerDelegate.java:34) ~[?:?]
at org.openhab.core.automation.module.script.rulesupport.internal.delegates.SimpleActionHandlerDelegate.execute(SimpleActionHandlerDelegate.java:59) ~[?:?]
at org.openhab.core.automation.internal.RuleEngineImpl.executeActions(RuleEngineImpl.java:1189) ~[bundleFile:?]
... 7 more