[SOLVED] ON/OFF in jython lib/python/personal script

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

def myrule(event):

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?

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…


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