Hi all,
I started to play with the Jython rule support: I tryed lo load 2 simple rules, and seems that the second loaded script overwrite the first one:
12:54:11.097 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script 'jsr223_Script01.py'
12:54:13.065 [INFO ] [smarthome.event.RuleAddedEvent ] - Rule 'scripted_000000000000001F' has been added.
12:54:13.068 [INFO ] [smarthome.event.RuleStatusInfoEvent ] - scripted_000000000000001F updated: INITIALIZING
12:54:13.120 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script 'jsr223_test.py'
12:54:13.130 [INFO ] [smarthome.event.RuleStatusInfoEvent ] - scripted_000000000000001F updated: IDLE
12:54:13.146 [INFO ] [smarthome.event.RuleAddedEvent ] - Rule 'scripted_000000000000001F' has been added.
12:54:13.156 [INFO ] [smarthome.event.RuleStatusInfoEvent ] - scripted_000000000000001F updated: INITIALIZING
12:54:13.161 [INFO ] [smarthome.event.RuleStatusInfoEvent ] - scripted_000000000000001F updated: IDLE
12:54:14.022 [INFO ] [smarthome.event.RuleStatusInfoEvent ] - scripted_000000000000001F updated: RUNNING
12:54:14.025 [INFO ] [smarthome.event.RuleStatusInfoEvent ] - scripted_000000000000001F updated: IDLE
12:54:15.011 [INFO ] [smarthome.event.RuleStatusInfoEvent ] - scripted_000000000000001F updated: RUNNING
12:54:15.014 [INFO ] [smarthome.event.RuleStatusInfoEvent ] - scripted_000000000000001F updated: IDLE
and I wondering from where the name
'scripted_000000000000001F'
come from?
The scripts are:
1° script
scriptExtension.importPreset("RuleSupport")
scriptExtension.importPreset("RuleSimple")
class myRule(SimpleRule):
def execute(self, modules, inputs):
print "Hello World from Jython"
sRule = myRule()
sRule.setTriggers([Trigger("aTimerTrigger", "timer.GenericCronTrigger", Configuration({"cronExpression": "0/15 * * * * ?"}))])
automationManager.addRule(sRule)
2° script
scriptExtension.importPreset("RuleSupport")
scriptExtension.importPreset("RuleSimple")
class myRule01(SimpleRule):
def execute(self, modules, inputs):
print "BYE BYE"
sRule = myRule01()
sRule.setTriggers([Trigger("aTimerTrigger", "timer.GenericCronTrigger", Configuration({"cronExpression": "* * * * * ?"}))])
automationManager.addRule(sRule)
Thanks in advance.
Anyway, for want to use Jython support on windows, the following line should be added to the file “openhab2 folder\runtime\bin\karaf.bat”
set JYTHON_HOME=C:\jython2.7.0
set EXTRA_JAVA_OPTS=-Dpython.home=%JYTHON_HOME% -Dpython.path=conf\automation\jsr223
set CLASSPATH="C:\jython2.7.0\jython.jar"