Platform Information
- Hardware: Raspberry Pi 3B+
- OS: Raspberry Pi OS (32 Bit - Buster)
- Java Runtime Environment:
- openjdk version “1.8.0_152”
- OpenJDK Runtime Environment (Zulu Embedded 8.25.0.76-linux-aarch32hf) (build 1.8.0_152-b76)
- OpenJDK Client VM (Zulu Embedded 8.25.0.76-linux-aarch32hf) (build 25.152-b76, mixed mode, Evaluation)
- openHAB 2.5.5 (Release Build)
Hello Community,
I’m migrating my rules to the NGRE, and I ran across a “Minimum higher than maximum range in cron expression.”
Original Expression: @when(“Time cron 0 30 22 ? * SUN-THU *”)
Error Free Expression: @when(“Time cron 0 30 22 ? * MON,TUE,WED,THU,SUN *”)
I suspect I’m getting the error because the day range is not considered valid. Why is this? The original expression works in the Rules DSL Engine, so wondering what the technical explanation is.
Exception
2020-06-06 16:00:32.369 [DEBUG] [jsr223.jython.core.rules ] - Added rule [Lights Out at 2230 (Sunday-Thursday)]
2020-06-06 16:00:32.375 [ERROR] [ore.common.registry.AbstractRegistry] - Cannot inform the listener "org.openhab.core.automation.internal.RuleEngineImpl$2@12a853c" about the "ADDED" event: Minimum higher than maximum range in cron expression '0 30 22 ? * SUN-THU *' in field 'DayOfWeek': min: 8, max: 5
java.lang.IllegalArgumentException: Minimum higher than maximum range in cron expression '0 30 22 ? * SUN-THU *' in field 'DayOfWeek': min: 8, max: 5
at org.eclipse.smarthome.core.internal.scheduler.CronAdjuster.parseRange(CronAdjuster.java:434) ~[?:?]
at org.eclipse.smarthome.core.internal.scheduler.CronAdjuster.parseSub(CronAdjuster.java:280) ~[?:?]
at org.eclipse.smarthome.core.internal.scheduler.CronAdjuster.parse(CronAdjuster.java:228) ~[?:?]
at org.eclipse.smarthome.core.internal.scheduler.CronAdjuster.<init>(CronAdjuster.java:98) ~[?:?]
at org.eclipse.smarthome.core.internal.scheduler.CronSchedulerImpl.schedule(CronSchedulerImpl.java:67) ~[?:?]
at org.eclipse.smarthome.core.internal.scheduler.CronSchedulerImpl.schedule(CronSchedulerImpl.java:61) ~[?:?]
at org.openhab.core.automation.internal.module.handler.GenericCronTriggerHandler.scheduleJob(GenericCronTriggerHandler.java:59) ~[?:?]
at org.openhab.core.automation.internal.module.handler.GenericCronTriggerHandler.setCallback(GenericCronTriggerHandler.java:55) ~[?:?]
at org.openhab.core.automation.internal.RuleEngineImpl.lambda$0(RuleEngineImpl.java:642) ~[?:?]
at java.util.ArrayList.forEach(ArrayList.java:1257) ~[?:1.8.0_152]
at java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1080) ~[?:1.8.0_152]
at org.openhab.core.automation.internal.RuleEngineImpl.register(RuleEngineImpl.java:639) ~[?:?]
at org.openhab.core.automation.internal.RuleEngineImpl.activateRule(RuleEngineImpl.java:856) ~[?:?]
at org.openhab.core.automation.internal.RuleEngineImpl.setRule(RuleEngineImpl.java:504) ~[?:?]
at org.openhab.core.automation.internal.RuleEngineImpl.addRule(RuleEngineImpl.java:464) ~[?:?]
at org.openhab.core.automation.internal.RuleEngineImpl$2.added(RuleEngineImpl.java:272) ~[?:?]
at org.openhab.core.automation.internal.RuleEngineImpl$2.added(RuleEngineImpl.java:1) ~[?:?]
at org.eclipse.smarthome.core.common.registry.AbstractRegistry.notifyListeners(AbstractRegistry.java:346) ~[?:?]
at org.eclipse.smarthome.core.common.registry.AbstractRegistry.notifyListenersAboutAddedElement(AbstractRegistry.java:379) ~[?:?]
at org.openhab.core.automation.internal.RuleRegistryImpl.notifyListenersAboutAddedElement(RuleRegistryImpl.java:240) ~[?:?]
at org.openhab.core.automation.internal.RuleRegistryImpl.notifyListenersAboutAddedElement(RuleRegistryImpl.java:1) ~[?:?]
at org.eclipse.smarthome.core.common.registry.AbstractRegistry.added(AbstractRegistry.java:157) ~[?:?]
at org.openhab.core.automation.internal.RuleRegistryImpl.added(RuleRegistryImpl.java:405) ~[?:?]
at org.openhab.core.automation.internal.RuleRegistryImpl.added(RuleRegistryImpl.java:1) ~[?:?]
at org.eclipse.smarthome.core.common.registry.AbstractRegistry.added(AbstractRegistry.java:1) ~[?:?]
at org.openhab.core.automation.module.script.rulesupport.shared.ScriptedRuleProvider.addRule(ScriptedRuleProvider.java:56) ~[?:?]
at org.openhab.core.automation.module.script.rulesupport.shared.RuleSupportRuleRegistryDelegate.add(RuleSupportRuleRegistryDelegate.java:73) ~[?:?]
at org.openhab.core.automation.module.script.rulesupport.shared.ScriptedAutomationManager.addRule(ScriptedAutomationManager.java:179) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_152]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_152]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_152]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_152]
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:186) ~[?:?]
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:204) ~[?:?]
at org.python.core.PyObject.__call__(PyObject.java:478) ~[?:?]
at org.python.core.PyObject.__call__(PyObject.java:482) ~[?:?]
at org.python.core.PyMethod.__call__(PyMethod.java:141) ~[?:?]
at core.rules$py.addRule$7(/etc/openhab2/automation/lib/python/core/rules.py:130) ~[?:?]
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:138) ~[?:?]
at org.python.core.PyFunction.__call__(PyFunction.java:413) ~[?:?]
at core.rules$py.rule_decorator$2(/etc/openhab2/automation/lib/python/core/rules.py:86) ~[?:?]
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:138) ~[?:?]
at org.python.core.PyFunction.__call__(PyFunction.java:413) ~[?:?]
at org.python.pycode._pyx44.f$0(<script>:114) ~[?:?]
at org.python.pycode._pyx44.call_function(<script>) ~[?:?]
at org.python.core.PyTableCode.call(PyTableCode.java:167) ~[?:?]
at org.python.core.PyCode.call(PyCode.java:18) ~[?:?]
at org.python.core.Py.runCode(Py.java:1386) ~[?:?]
at org.python.core.__builtin__.eval(__builtin__.java:497) ~[?:?]
at org.python.core.__builtin__.eval(__builtin__.java:501) ~[?:?]
at org.python.util.PythonInterpreter.eval(PythonInterpreter.java:259) ~[?:?]
at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:40) ~[?:?]
at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:47) ~[?:?]
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:249) ~[?:1.8.0_152]
at org.openhab.core.automation.module.script.internal.ScriptEngineManagerImpl.loadScript(ScriptEngineManagerImpl.java:156) ~[?:?]
at org.openhab.core.automation.module.script.rulesupport.internal.loader.ScriptFileWatcher.importFile(ScriptFileWatcher.java:176) ~[?:?]
at org.openhab.core.automation.module.script.rulesupport.internal.loader.ScriptFileWatcher.processWatchEvent(ScriptFileWatcher.java:143) ~[?:?]
at org.eclipse.smarthome.core.service.WatchQueueReader.lambda$3(WatchQueueReader.java:323) ~[?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_152]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_152]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_152]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:1.8.0_152]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_152]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_152]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_152]
Rule
from core.rules import rule
from core.triggers import when
from core.actions import ScriptExecution
from datetime import datetime
@rule("Lights Out at 2230 (Sunday-Thursday)")
@when("Time cron 0 30 22 ? * SUN-THU *")
def lights_out_at_2230_sunday_through_thursday(event):
global Lights_Out_Timer
item_Front_Porch_Lights=itemRegistry.getItem("Front_Porch_Lights")
item_gKitchen_Island_Lights=itemRegistry.getItem("gKitchen_Island_Lights")
item_Kitchen_Over_Cabinet_Lights=itemRegistry.getItem("Kitchen_Over_Cabinet_Lights")
item_Kitchen_Under_Cabinet_Lights=itemRegistry.getItem("Kitchen_Under_Cabinet_Lights")
item_gKitchen_Table_Lights=itemRegistry.getItem("gKitchen_Table_Lights")
item_gDining_Room_Lights=itemRegistry.getItem("gDining_Room_Lights")
item_gFamily_Room_Lights=itemRegistry.getItem("gFamily_Room_Lights")
item_Bar_Light=itemRegistry.getItem("Bar_Light")
item_gFireplace_Light=itemRegistry.getItem("gFireplace_Light")
item_Sunroom_Window_Lights=itemRegistry.getItem("Sunroom_Wndow_Lights")
item_gPatio_Lights=itemRegistry.getItem("gPatio_Lights")
item_gFoyer_Light=itemRegistry.getItem("gFoyer_Light")
item_gLiving_Room_Lights=itemRegistry.getItem("gLiving_Room_Lights")
item_gUpstairs_Hallway_Lights=itemRegistry.getItem("gUpstairs_Hallway_Lights")
item_Balcony_Light=itemRegistry.getItem("Balcony_Light")
item_Fish_Tank_Light=itemRegistry.getItem("Fish_Tank_Light")
item_Front_Porch_Lights.send(OFF)
item_gKitchen_Island_Lights.send(OFF)
item_Kitchen_Over_Cabinet_Lights.send(OFF)
item_Kitchen_Under_Cabinet_Lights.send(OFF)
item_gKitchen_Table_Lights.send(OFF)
item_gDining_Room_Lights.send(OFF)
item_Fish_Tank_Light.send(ON)
item_gFamily_Room_Lights.send(OFF)
item_Bar_Light.send(OFF)
item_gFireplace_Light.send(OFF)
item_Sunroom_Window_Lights.send(OFF)
item_gPatio_Lights.send(OFF)
item_gFoyer_Light.send(OFF)
item_gLiving_Room_Lights.send(OFF)
item_gUpstairs_Hallway_Lights.send(OFF)
item_Balcony_Light.send(ON)
#Lights_Out_Timer = ScriptExecution.createTimer(DateTime.now().plusMinutes(10)
if item_Balcony_Light == ON:
if Lights_Out_Timer is None or str(Lights_Out_Timer.getState()) == "TERMINATED":
Lights_Out_Timer = Timer(1200, lambda: events.sendCommand("Balcony_Light", "OFF"))
Lights_Out_Timer.start()
Regards,
Burzin