[SOLVED] Unhandled exception for timer rule

  • Platform information:
    • Hardware: amd64/6gb/hp microserver n40l
    • OS: debian testing
    • Java Runtime Environment: zulu 8.31.0.1
    • openHAB version: 2.4 (from the deb repo)
  • Issue of the topic: I have a rule that turns on a circulation pump at the same time a light is turned on and turns it off after 3 minutes. It works, but gives an unhandled exception every time the rule fires and I’d like to know why. (Before you suggest using the expire binding, I tried that, but it only works when I set the expiration time to 1m, but it doesn’t work for longer periods). This is the rule:
var Timer CirculationTimer = null

rule "Cirkulacios szivattyu furdoszoba villanyra"

when
    Item UBathroom changed from OFF to ON
then
      Cirkulacios.sendCommand(ON)
      CirculationTimer = createTimer(now.plusMinutes(3)) [|
        Cirkulacios.sendCommand(OFF)
        CirkulationTimer = null
      ]
end

and this is the log

10:45:27.339 [INFO ] [smarthome.event.ItemCommandEvent     ] - Item 'Cirkulacios' received command OFF                                      
10:45:27.339 [ERROR] [org.quartz.core.JobRunShell          ] - Job DEFAULT.2018-12-31T10:45:27.327+01:00: Proxy for org.eclipse.xtext.xbase.l
ib.Procedures$Procedure0: [ | {                                                                                                              
  <XFeatureCallImplCustom>.sendCommand(<XFeatureCallImplCustom>)                                                                             
  <null>.CirkulationTimer = <XNullLiteralImplCustom>                                                                                         
} ] threw an unhandled Exception:                                                                                                            
java.lang.IllegalArgumentException: Couldn't invoke 'assignValueTo' for feature JvmVoid:  (eProxyURI: circulation.rules#|::0.2.0.2.0.1.7.6.1$
1.0.1::0::/1)                                                                                                                                
        at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.assignValueTo(XbaseInterpreter.java:1225) ~[?:?]                       
        at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:1213) ~[?:?]                          
        at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:216) ~[?:?]                           
        at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.doEvaluate(ScriptInterpreter.java:226) ~[?:?]                   
        at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:204) ~[?:?]                      
        at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:447) ~[?:?]
        at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:228) ~[?:?]
        at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.doEvaluate(ScriptInterpreter.java:226) ~[?:?]
        at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:204) ~[?:?]
        at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.evaluate(XbaseInterpreter.java:190) ~[?:?]
        at org.eclipse.xtext.xbase.interpreter.impl.ClosureInvocationHandler.doInvoke(ClosureInvocationHandler.java:46) ~[?:?]
        at org.eclipse.xtext.xbase.interpreter.impl.AbstractClosureInvocationHandler.invoke(AbstractClosureInvocationHandler.java:29) ~[?:?]
        at com.sun.proxy.$Proxy145.apply(Unknown Source) ~[?:?]
        at org.eclipse.smarthome.model.script.internal.actions.TimerExecutionJob.execute(TimerExecutionJob.java:49) ~[?:?]
        at org.quartz.core.JobRunShell.run(JobRunShell.java:202) [107:org.eclipse.smarthome.core.scheduler:0.10.0.oh240]
        at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) [107:org.eclipse.smarthome.core.scheduler:0.10.0.oh2
40]
10:45:27.340 [INFO ] [nding.souliss.internal.SoulissBinding] - receiveCommand - Cirkulacios = OFF - Typical: 0x11
10:45:27.365 [ERROR] [org.quartz.core.ErrorLogger          ] - Job (DEFAULT.2018-12-31T10:45:27.327+01:00: Proxy for org.eclipse.xtext.xbase.
lib.Procedures$Procedure0: [ | {
  <XFeatureCallImplCustom>.sendCommand(<XFeatureCallImplCustom>)
  <null>.CirkulationTimer = <XNullLiteralImplCustom>
} ] threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception.
        at org.quartz.core.JobRunShell.run(JobRunShell.java:213) [107:org.eclipse.smarthome.core.scheduler:0.10.0.oh240]
        at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) [107:org.eclipse.smarthome.core.scheduler:0.10.0.oh2
40]
Caused by: java.lang.IllegalArgumentException: Couldn't invoke 'assignValueTo' for feature JvmVoid:  (eProxyURI: circulation.rules#|::0.2.0.2
.0.1.7.6.1.1.0.1::0::/1)
        at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.assignValueTo(XbaseInterpreter.java:1225) ~[?:?]
        at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:1213) ~[?:?]
        at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:216) ~[?:?]
        at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.doEvaluate(ScriptInterpreter.java:226) ~[?:?]
        at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:204) ~[?:?]
        at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:447) ~[?:?]
        at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:228) ~[?:?]
        at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.doEvaluate(ScriptInterpreter.java:226) ~[?:?]
        at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:204) ~[?:?]
        at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.evaluate(XbaseInterpreter.java:190) ~[?:?]
        at org.eclipse.xtext.xbase.interpreter.impl.ClosureInvocationHandler.doInvoke(ClosureInvocationHandler.java:46) ~[?:?]
        at org.eclipse.xtext.xbase.interpreter.impl.AbstractClosureInvocationHandler.invoke(AbstractClosureInvocationHandler.java:29) ~[?:?]
        at com.sun.proxy.$Proxy145.apply(Unknown Source) ~[?:?]
        at org.eclipse.smarthome.model.script.internal.actions.TimerExecutionJob.execute(TimerExecutionJob.java:49) ~[?:?]
        at org.quartz.core.JobRunShell.run(JobRunShell.java:202) ~[?:?]
        ... 1 more
10:45:27.644 [INFO ] [smarthome.event.ItemStateChangedEvent] - Cirkulacios changed from ON to OFF

Try that, you don’t need the timer variable, in your case:

rule "Cirkulacios szivattyu furdoszoba villanyra"
when
    Item UBathroom changed from OFF to ON
then
    Cirkulacios.sendCommand(ON)
    createTimer(now.plusMinutes(3), [ |
        Cirkulacios.sendCommand(OFF)
    ])
end
1 Like

Thanks, this works perfectly. I’ll spend some more time reading things, but hopefully it won’t hurt if the switch is turned off and back on again while this timer is running - it will only extend it with an additional 3 minutes right?

No, the first timer will turn off after 3 minutes
And the rule will create another timer that will turn off after 3 minutes.
For your case the rule need some work and you will need the timer variable.
I am at work now, maybe tonight

Thanks, the only important thing is that the pump turns off (I won’t mind if it’s running for 3 minutes or 6, but it should turn off eventually). Cheers :slight_smile:

Typo in your first rule

2 Likes

Eagle eye!

If you want the timer to reset if the light is turned on again then:

var Timer CirculationTimer = null

rule "Cirkulacios szivattyu furdoszoba villanyra"

when
    Item UBathroom changed from OFF to ON
then
    if (CirculationTimer === null) {
        Cirkulacios.sendCommand(ON)
        CirculationTimer = createTimer(now.plusMinutes(3), [ |
            Cirkulacios.sendCommand(OFF)
            CirculationTimer = null
        ])
    } else {
        CirculationTimer.reschedule(now.plusMinutes(3))
    }
end
1 Like

Thanks Vincent! One question about the code, this curretly extends the timer to another 3 minutes when the switch is turned on while the timer is running, right? So when the timer was running for 2 minutes and the switch is turned on again, the pump will work for 5 minutes altogether (unless somebody pushes the switch again)?

Correct

1 Like