Rules stopped working after upgrading to OH3

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.

rule “Heating Governor”
when
Item Heating_Monitoring_Temp changed or
Item Heating_Temp changed
then
var Number house_heat = (Heating_Monitoring_Temp.state as Number)
var Number heat_setpoint = (Heating_Temp.state as Number)
val Number offset = 0.4
if (house_heat >= (heat_setpoint + offset)) {
ZWaveNode016SSR302TwoChannelBoilerActuator_Switch.sendCommand(OFF)
} else if (house_heat < (heat_setpoint - offset)) {
ZWaveNode016SSR302TwoChannelBoilerActuator_Switch.sendCommand(ON)
}
end

My version of boiler on off depending on temp
Curious Why do you have

FloorThermostatSTP.state as DecimalType

And then

FloorThermostatSTP.state as Number

My version of boiler on off depending on temp

@garyfree You are right, triggering on temperature and setpoint change would result less execution. I will modify my rule

Curious Why do you have
FloorThermostatSTP.state as DecimalType
And then
FloorThermostatSTP.state as Number

Thanks for pointing out, this was unintentional… Casting to Number should be the right one here.

I had the same issue as the OP. When I moved to OH 3.0.1, my rules worked if I used the config files. When I moved them to the Main UI they stopped working. I could trigger them manually, but the timed events did not trigger. They are only simple rules to turn on/off lights at certain times.
Interestingly, when I upgraded to OH 3.1, the rules started working properly. But, unfortunately, the upgrade broke other things, like MyOpenhab. I’m still working on that one.

Make sure you are running the correct version of Java.
My rules did not want to run on Java 16. Also no logging…
All got fixed when I went down to Java 11.

1 Like

Thank you @faf :grinning: This was the problem! My openHAB 3 ran on Java 17 without any obvious issues, execept that the rules just didn’t work anymore. There were no errors in the logs. With Java 11 the rules are back :+1:

For Ubuntu/Linux users: I posted instructions on how to configure the Java version for openHAB running as systemd-based service here. Just replace openhab2 with openhab and zulu8 with zulu11.