actually I have some major problems with the openhab rule-engine:
After a while (ranges from 10min to serveral hours) suddenly none of my rules are getting executed.
I still can see the logging from RuleEngine.execute (line 305: logger.debug("Executing rule '[…]) in my log but they did not get executed and I dont see their logs anymore (“start rule:” - see my example rule at the end).
When the rule excecution is broken I can see in debug that the xtext method call returns an empty list as result but no error message; result.getResult() returns ‘null’, no exception is thown (class: ScriptImpl, method: execute(IEvaand no error message.
I already tried to update from openhab 1.6 to 1.7, but the problem is still the same.
I also noticed that the FolderOberserver most the time is not working anymore when the rule problem occurs.
I think that the problem occurs much faster, if an action triggers multiple rules.
A restart fixes the problem for a while.
My rules looks like this:
import org.openhab.core.library.types.*
import java.util.Date
import java.text.SimpleDateFormat
import org.joda.time.*
rule "Lamp on"
when
Item item_000000001 received update
then
logInfo("start rule:", "Lamp on" )
if(item_000000001.state.toString().equals( "ON" ) ) {
logInfo("execute rule", "Lamp on" )
sendCommand(item_000000002, ON)
}
end
Has anybody have an idea how to solve this?
Thanks!
Tobias
I’ve not seen the Rule engine stop working, but openHAB versions prior to 1.7.0 had series Threading/Concurrency issues IF you had multiple Rules triggering from the same Item event.
Versions after 1.7.0 still have issues, but they’re far more isolated in nature, and depend upon the specific Bindings you have (and how they interact with DateTime objects)
Once you’re running 1.7.0 (or newer), you’ll want to paste (formatted) the Exception stacks you’re seeing, along with any Rules that could be triggering them… like whatever’s making result.getResult() calls if that happens to be in one-or-more of your rules.
Are there any backup scripts or something similiar, which touch the rules files?
Why do you import joda time there?
Maybe, loglevel TRACE would be more verbose?
Maybe one solution would be to write the rules in Python or JavaScript to get other log messages, because with your current rules you reach the XText beast, where logging seems to get very silent. :-/ Look at JSR233 in the openHAB Wiki how to do this. Hopefully, jython or nashorn/rhino will produce more helpful error messages.
Hi, I will build in the trace logging and post the logs as soon I was able to break the rule engine again. For now, this is what I remember from debugging:
It gets executed, the result is null when the rules are broken
The message is null and we exit with “return result.getResult()” (= null)
if(result==null) never gets true
result.getResult() is always null when broken
So it might be somewhere in xtext line 59:interpreter.evaluate(xExpression, evaluationContext, CancelIndicator.NullImpl)
xExpression and evaluationContext looked quite good, but the structure is too big for me to judge any difference to the correct working ones.
I just now had this problem. So I put an old rules file and add my change one by one and… A little mistake into my rules file, a var declaration outside a rule with an uppercase letter, Var. No error in log file of openhab and no rule starting. So you could verify that.