Why does this rule not fire?

I have a rule which was running last summer (I think OH 2.5) properly.
Since the upgrade to OH3 it does no longer work.
The log does not show any entry, even when I start the rule in main ui manually.

Following what I had in the rules file:

rule "Solarsteuerung ausschalten"
	Time cron "0 0/6 11-19 ? APR,MAY,JUN,JUL,AUG,SEP * *"
	if (DeltaSolSLTRegler_TemperaturSensor3.state > 77.6 && Solarsteuerung.state == ON) {
	sendCommand(Solarsteuerung, OFF)

It is a very simple rule and I have no idea why it does not fire.

I thought to delete the rule file and add it to main ui, but also does not work.
Following the main ui code:

configuration: {}
  - id: "1"
      cronExpression: 0 0/6 11-17 ? APR,MAY,JUN,JUL,AUG,SEP *
    type: timer.GenericCronTrigger
conditions: []
  - inputs: {}
    id: "2"
      type: application/vnd.openhab.dsl.rule
      script: |-
        if (DeltaSolSLTRegler_TemperaturSensor3.state > 77.6) {
          sendCommand(Solarsteuerung, OFF)
    type: script.ScriptAction

I have absolutely no idea why this very simple rule does not fire any more.
Any help is very much appreciated!

Without a logInfo line that would print onto the logs you can’t tell wether the rule really did not fire or your if statement is never true.

What kind of state does your item hold, only a number or a number with dimension?

Thanks for your reply.
Good finding, maybe the UoM was introduced between 2.5 and 3.
I changed the rule now to:

if (DeltaSolSLTRegler_TemperaturSensor3.state > 77.6 | °C) {
  sendCommand(Solarsteuerung, OFF)

I read the documentation about loginfo but honestly have no idea how to apply with a cron expression.
Before I switched to main ui i had:

logInfo("Solarsteuerung.rules", "Solarsteuerung" + Solarsteuerung.state.toString())

But I did not get any log entry.

Is your logInfo line inside or outside your ‘if’ statement? Put it outside to see the value in case there is an issue with the ‘if’ statement. You want to break this down to find out if the cron is firing, and if it is, then is the if statement working. Those are 2 questions to answer.

1 Like

Thank you for your suggestion.
I had the logInfo line inside the if-statement.
Put it outside now.
Today it will get very hot and sunny, so it should fire for sure in the afternoon.

Thanks John, logInfo works now:

2022-07-14 11:24:00.967 [INFO ] [.core.model.script.SolarsteuerungAUS] - SolarsteuerungON

:slightly_smiling_face: :+1:

Probably you want to add a second logInfo to get the state of the sensor as well:

logInfo("Solarsteuerung.rules", "DeltaSolSLTRegler_TemperaturSensor3: " + DeltaSolSLTRegler_TemperaturSensor3.state.toString())
logInfo("Solarsteuerung.rules", "Solarsteuerung: " + Solarsteuerung.state.toString())
1 Like

I don’t know if it makes a difference, but I format UoM without spaces in my rules.


Thanks to all!
Rule works again, UoM was the culprit.
Or more likely it was me as I did not take care about UoM …