JimT
(jimtng)
December 30, 2019, 4:20am
1
I have a script in conf/automation/lib/python/personal/test.py
def test():
return ON
I’m including that script from my rule, e.g.
from personal.test import test
@rule("something")
def myrule(event):
test()
However I am getting a python exception, which is caused by my referring to ON
inside the conf/automation/lib/python/personal/test.py
What do I need to do in order to have the same access to ON/OFF/OPEN/CLOSED etc. from within the personal library?
5iver
(Scott Rushworth)
December 30, 2019, 5:27am
2
This would not be a script, but a module in the personal package. To get access to the default script scope in a module, use core.jsr223.scope. Read this…
https://openhab-scripters.github.io/openhab-helper-libraries/Python/Reference.html#custom-packages-and-modules
I have an update to push with a cleaner example… use it like this…
from core.jsr223.scope import ON, OFF
Then read this to see what is available…
It’s always helpful when the errors are included in the posts!
1 Like