rule “Ueberwachung der Laufzeit bei Nachfuellung des Schwimmbades”
when
Item G_B_EffektWeiss received command
then
if(G_B_EffektWeiss.state == ON) {
nachf = createTimer(now.plusMinutes(1)) [|
NachfuellenWarnung.postUpdate(1)
sendMail …
sendMail …
]
} else {
NachfuellenWarnung.postUpdate(0)
nachf.cancel
nachf = null
}
end
When the Switch gets on everything is fine and the timer is starting. But when the Switch gets state off the timer does not end and in the openhab.log I receive this message:
Error during the execution of rule 'Ueberwachung der Laufzeit bei Nachfuellung des Schwimmbades': The name '<XFeatureCallImplCustom>.cancel' cannot be resolved to an item or type.
After trying cancel() I’m sorry to say that it did not solve the problem.
Error message now looks like:
Error during the execution of rule 'Ueberwachung der Laufzeit bei Nachfuellung des Schwimmbades': The name '<XFeatureCallImplCustom>.cancel()' cannot be resolved to an item or type.
But I’m sorry to say that this also did not work. The error message now:
Error during the execution of rule 'Ueberwachung der Laufzeit bei Nachfuellung des Schwimmbades': The name '<XFeatureCallImplCustom> != <XNullLiteralImpl>' cannot be resolved to an item or type.
Yes, I tried to import org.joda.time.* before but this did not Change anything.
I also don’t think that this is the Problem because the timer itself is working without any Problem. It is the cancellation of a running timer which runs into this errors.
Not true. You do have to import org.openhab.model.script.actions.* though. That will give you Timer. now is available without importing joda, though if you want to create or save now to some variable or convert DateTimes you do need to import it.
What I found out now is that it seems not to be a problem with the .cancel command itself. If I do a variable declaration like var Timer nachf within the rule no error occurs.
That means it seems that the global variable declaration does not take affect but I don’t know why and what I can do against this.
So the reason why this errors occure is only because he does not find the Timer.
If you make the declaration local to the rule but make no other changes, the else part with the cancel will never run. Every time the rule triggers nachf will be then either you create a new timer (i.e G_B_EffektWeiss.state == ON) or nachf will be null so the call to nachf.cancel never occurs. In short, unless you made other changes you are not testing the broken call at all.
Did you copy and paste your code exactly or did you retype it? Is it possible that you have a typo causing a mispelling of nachf?
The latest error that pops up once you added the if(nachf != null) clearly indicates that nachf doesn’t exist (not that it is null, it doesn’t exist at all).
@Kai postet there that both packages, the java.util.* and org.joda.time (which is loaded by default) hold a class called “Timer”. If both packages are loaded there is a conflict loading this class.