Cron OR not working

Can anyone tell me why this rule never fires:

rule "test"
when
Time cron “0 45 07 * * ?” or
Time cron “0 45 08 * * ?” or
Time cron “0 45 09 * * ?” or
Time cron “0 45 10 * * ?” or
Time cron “0 45 11 * * ?” or
Time cron “0 45 12 * * ?” or
Time cron “0 45 13 * * ?” or
Time cron “0 45 14 * * ?” or
Time cron “0 45 15 * * ?” or
Time cron “0 45 16 * * ?” or
Time cron “0 45 17 * * ?” or
Time cron “0 45 18 * * ?” or
Time cron “0 45 19 * * ?” or
Time cron “0 45 20 * * ?” or
Time cron “0 45 21 * * ?” or
Time cron “0 45 22 * * ?” or
Time cron “0 45 23 * * ?” or
Time cron “0 45 00 * * ?” or
Time cron “0 45 01 * * ?” or
Time cron “0 45 02 * * ?” or
Time cron “0 45 03 * * ?” or
Time cron “0 45 04 * * ?” or
Time cron “0 45 05 * * ?” or
Time cron "0 45 06 * * ?“
then
sendMail("www@gmail.com”, “Forecast and Blowing Temps”, "AC State/DesiredCool/CurrentTemp: " + EcoBeeEquipmentStatus.state + " " + runtime_desiredCool.state + " " + remoteSensors_hall_capability_temperature.state + "\nForecast: " + weather_forecasts0_temperature.state + "\nBlowingTemp: " + Laundry_Temperature.state + “”)
end

There was a known issue with multiple cron expressions, combined through “or”:

Looks like it has been fixed, but you need to update to the latest snapshot, I guess.

Thanks!

Hi Rich,

Not directly related to your question, and I am pretty rusty with cron, but I am curious… seeing your when clause makes me think you could accomplish the same result with 1 line.

Time cron “0 45 * * * ?”

Is that rule to fire at the 45 minute, 0 second mark of every hour?

cheers,
craig

You may be rusty, but I am a complete noob.
I will look into that.

Thanks!

@craigh @milty456 this might be helpful :wink:

Time cron "0 45 * ? * * *"

I used that second link and that generator to make the following:
Tried the following, rule never runs:
I’d expect that to fire every 15 minutes
rule "test"
when
Time cron “0 */15 * ? * *”

then
sendMail("xxx@gmail.com", “Forecast and Blowing Temps”, "LastTimeON: " + EcoBeeLastTimeOn.state + "\nLastTimeOff: " + EcoBeeLastTimeOff.state + "\nAC State/DesiredCool/CurrentTemp: " + EcoBeeEquipmentStatus.state + " " + runtime_desiredCool.state + " " + remoteSensors_hall_capability_temperature.state + "\nForecast: " + weather_forecasts0_temperature.state + "\nBlowingTemp: " + Laundry_Temperature.state + “”)

end

Time cron "0 */15 * * * ?"

Although I’m not a cron specialist, the above cron job is running fine since almost three years with openHAB …

Maybe you should replace the then part with a simple logInfo:

logInfo("FILE", "cron has fired")

1 Like

Thanks i figured it out.
It does work.

I copied a rule and pasted it.
I left the same “rule name” and what it was doing(which is weird) is running the original rule at the interval and not running the new rule at all…weird.

FYI this bug was fixed with: https://github.com/eclipse/smarthome/pull/3326
The fix is part of the latest openHAB snapshot builds and will be included in the next stable build.

If you are currently suffering from this bug, your options are (1) reduce your rule to one cron condition, (2) wait for the openHAB 2.1 stable release or (3) switch to the unstable branch and use the latest snapshot.

If you did one of the above and still encounter problems, they are probably unrelated to the bug discussed here. Please search the forum for similar cases or create a new thread.