Rules stopped working after upgrading to OH3

Hi,

I have recently upgraded from OH 2.5 to 3.0. My rules stopped working.
I don’t receive any related error messages from the RuleStatusInfoEvent Logger on any levels.
I created a trivial test rules file to update some items, but this does not take effect on the items either.

Could you please help me with some ideas what should I investigate further? Thanks!

Debug log:

2020-12-31 09:45:51.819 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘test.rules’
2020-12-31 09:45:51.836 [DEBUG] [er.antlr.AbstractInternalAntlrParser] - Parsing took: 5 ms
2020-12-31 09:45:51.839 [DEBUG] [.linking.impl.AbstractCleaningLinker] - beforeModelLinked took: 1ms
2020-12-31 09:45:51.845 [DEBUG] [.linking.impl.AbstractCleaningLinker] - doLinkModel took: 5ms
2020-12-31 09:45:51.846 [DEBUG] [.linking.impl.AbstractCleaningLinker] - afterModelLinked took: 2ms
2020-12-31 09:45:51.900 [DEBUG] [pse.xtext.util.OnChangeEvictingCache] - Clear 113 cache entries for resource tmp_test.rules after 9 hits and 113 misses (quota: 7%)
2020-12-31 09:45:51.973 [DEBUG] [pse.xtext.util.OnChangeEvictingCache] - Clear 137 cache entries for resource tmp_test.rules after 257 hits and 137 misses (quota: 65%)
2020-12-31 09:45:51.975 [DEBUG] [pse.xtext.util.OnChangeEvictingCache] - Clear 126 cache entries for resource test.rules after 46635 hits and 126 misses (quota: 99%)
2020-12-31 09:45:51.992 [DEBUG] [er.antlr.AbstractInternalAntlrParser] - Parsing took: 3 ms
2020-12-31 09:45:51.993 [DEBUG] [.linking.impl.AbstractCleaningLinker] - beforeModelLinked took: 0ms
2020-12-31 09:45:51.995 [DEBUG] [.linking.impl.AbstractCleaningLinker] - doLinkModel took: 2ms
2020-12-31 09:45:51.996 [DEBUG] [.linking.impl.AbstractCleaningLinker] - afterModelLinked took: 1ms
2020-12-31 09:45:52.022 [DEBUG] [pse.xtext.util.OnChangeEvictingCache] - Clear 113 cache entries for resource test.rules after 9 hits and 113 misses (quota: 7%)

Update: I copied the rule definitions to new rules files, after this the rules appeared on the UI and they are executable and doing their job. So the issue is that neither the system started, neither the time based rules are executed by the system. Any suggestions welcomed.

i’m not sure how anyone should help you with the information you share. What exactely isn’t working? Can you give an example?

1 Like

I have rules that should run every minute. These rules are not firing since the upgrade. But if I trigger them from the UI, then they are running fine. What could go wrong with the execution of time based rules?

uhh, this one is tough…

Then show us this rule?

Here is one of the rules below… (I created a trivial one as well, which does not fire automatically either)

rule "FloorHeating"
  when 
    Time cron "0 * * * * ?"
  then  
    if (TemperatureFloor.state < ((FloorThermostatSTP.state as DecimalType)-0.2 ) ) {
      if (FloorHeater.state == OFF) {
        FloorHeater.sendCommand(ON)
        postUpdate(Heating_Cooling_Mode,"Heating")
      }
    }

    else if ((TemperatureFloor.state) > ((FloorThermostatSTP.state as Number)+0.2) ) {
      if (FloorHeater.state == ON) {
        FloorHeater.sendCommand(OFF)
        postUpdate(Heating_Cooling_Mode,"Off")
      }
    }
end

I would write to the log file to see where the problem is:
logInfo(“Floor Heating rule”, The variable you want to know what it is)

I think your condition is not met.

http://yourtopenhabserverip:9001 should show the frontail log with your logInfo

Hi, The problem is not with the code. As I wrote, the rule is executing properly if I trigger it manually from UI. The problem is that the rule is not triggered every minute, it isn’t not executed by the system.

Call me stupid, but how do you see that it is or is not triggered without logging? Serious question, I’m no expert either.

i cannot tell you what can go wrong during update what prevents cron from working… i get your problem now, but am not pretty sure how to solve it…

Because these problems are not common it’s maybe a useful advice to setup OH3 from scratch and migrate things over…

You can see it on eventually updating events for example…

Yeah, ok. The usual stuff, but there’s no “Rule … now executing” in the log except I put it in the rule.

Ok, I created a trivial rule, @schossel… You will love this, but it unfortunately reassures my problem.
@spy0r Thanks for the suggestion, I fight for this a bit more and I will do a clean one.

rule "Testrule"
  when 
    Time cron "0 * * * * ?"
  then
    var Number NewCounter=(TestCounter.state as Number)+1
    TestCounter.postUpdate(NewCounter) 
    logInfo("logThermostat","TestCounter incremented {}", NewCounter)
end

A simple
logInfo(“logThermostat”,“Seems working”)

Which should show in the log every minute would have done the trick and the less complicated the better. It is just for testing.
You didn’t even post a conclusion of your test. You just wrote your code.

I wrote this reassures the problem. The rule is running on manual trigger and incrementing the test item and put the message into the log. But it does not run every minute.

Did you reboot?

Did you have a look into the log while booting, sometimes on my OH some things have errors and after a second reboot they work as intended.

Check your system time. I have the time displaying on my sitemap and it is way off. I have been having a heck of a time fixing it. I have edited my locale, time zone, etc. The 3.0 system is so different that I’m having a hard time finding things.

I purged openhab and re-installed and restored the previous configuration.
Unfortunately the rules still not executed…
Checked system time, that is sharp.

should it be

Time cron "0 * * * * ? *"
2 Likes

The solution for the problem was to rebuild OH3 from scratch. I wiped the OS, reinstalled Openhabian and OH3. I did not restore the Openhab backup to avoid migrating potential database issues. I installed the necessary addons, bindings, transformation manually from UI, then deployed the config files to restore my config. Rules worked fine after this. This was much less of a work than I expected.