[SOLVED] Cron with Day stopped working

I’ve had a set of rules that have a combination of Timer triggers which had been functioning properly for over a year. We recently had some power outages and the rules do not trigger as before. The rules that are triggered based on a time of day with no additional conditions trigger. Anything Timers with additional conditions (e.g., day of week, specific month/day day of year) no longer trigger. I extracted the triggers of the affected rules and placed them in their own .rules file with minimal actions (logging when they trigger). They exhibit the same behavior. cron Test 1 does not trigger at all because every Timer has specific day of week or day of year. cron Test 2 only triggers at 7:30 am (because the Timerdoes not specify any other conditions). Again, these exact triggers used to work and just quite working in the last couple of weeks (I just noticed we were missing these because our COVID-19 work schedules blew up our morning routines.

Kernel: Linux 4.19.66-v7+ #1253 SMP Thu Aug 15 11:49:46 BST 2019 armv7l
Release: Raspbian GNU/Linux 9 (stretch)
Platform: Raspberry Pi 3 Model B Rev 1.2
openHAB 2.5.0-1 (Release Build)
openHABian

The date & time on the Raspberry Pi is correct and syncs with NTP.

Log output

2020-06-08 07:30:00.093 [INFO ] [ipse.smarthome.model.script.myHouse] - Running rule cron Test 2

cron_test.rules

rule "cron Test 1"
when
    Time cron "0 20 07 2-31 1 ? *" or // Jan 2-31
    Time cron "0 20 07 ? 2-5 MON-FRI *" or // Feb-May
    Time cron "0 20 07 15-31 8 ? *" or // Aug 15-31
    Time cron "0 20 07 ? 9-11 MON-FRI *" or  // Sep.-Nov
    Time cron "0 20 07 1-24 12 ? *" or // Dec 1-24
    Time cron "0 30 08 ? * SUN" // Every Sunday
then
    logInfo("myHouse", "Running rule cron Test 1")
end

rule "cron Test 2"
when
    // Turn on at 7:15 on school days, 7:30 otherwise
    Time cron "0 15 07 2-31 1 ? *" or // Jan 2-31
    Time cron "0 15 07 ? 2-5 MON-FRI *" or // Feb-May
    Time cron "0 15 07 15-31 8 ? *" or // Aug 15-31
    Time cron "0 15 07 ? 9-11 MON-FRI *" or  // Sep.-Nov
    Time cron "0 15 07 1-24 12 ? *" or // Dec 1-24
    Time cron "0 30 07 ? * * *" // Every Day (for non-school weekdays)

then
    logInfo("myHouse", "Running rule cron Test 2")
end

Any clues and guidance much appreciated.

Mike

Use the new rule engine, which has a completely reworked scheduler that came out about 1.5 years ago.

The solution to repair something that has been working for months is to learn a new rules engine and recreate existing rules? Ouch!

1 Like

I’m sorry, but there’s no way to repair something that has been removed from the code base! The fixes to your problem are in the new scheduler, which is used by the new rule engine. There will be no more updates to openhab-core until OH 3.0. The old rule engine has already been removed in OH 3.0. It looks like the rules DSL will be kludged up in some form and grafted onto the new rule engine. So, you have two options to resolve the issue… 1) live with it until OH 3.0 and then migrate to the new rules DSL (assuming it works, gets merged, you don’t mind the possible migration of your rules to get them working, etc.), or 2) migrate this rule to scripted automation, which is MUCH better than the DSL.

You don’t have to migrate all of your rules! in OH 2.5.x, you can use both the old and new rule engines at the same time. But once you migrate one rule, you will WANT to migrate them all! Yes, it’s that good!

I did not upgrade OH. I did not perform an upgrade/update/apt-get install. Nothing. Nada. Was working. Reboot. Stopped working. No codebase changes.

The rule triggers for Time cron "0 30 07 ? * * *" (using the “old”(?) cron rule trigger) but the same “old” cron rule trigger with a cron expression that include more than just a time of day has stopped working.

I’m not a big fan of PaperUI and all of the excessive point and click. I installed the NGRE (Experimental). NGRE didn’t change my mind about PaperUI.

Disclaimer, I did not take the time to relearn rules using the NGRE. I created a new rule through the NGRE and started adding triggers (via the exact same cron expressions). This took a good 5-10 minutes to point and click through it all compared to rules via cut & paste and a few seconds editing the triggers/expressions. I got to the part where it asked me to reference a rule to run and that’s where I stopped. So now I have a rule trigger that calls another rule but I don’t know how to create the other rule and does it have to have its own trigger, etc… and all I wanted to do was to have an action to log some text… and doing that was not in the list of actions.

I admit that I am not a DSL fan. But I have invested a ton of hours to become dangerous with DSL… and to know how to clone code snippets to create new automations. I guess I can start over and learn JSR223. But I’m not going to switch to point and click. It’s just requires to much repetitive action and consume too much time for even simple actions.

That’s a big “once”.

Maybe it’s time to learn YAML :smirk:

Mike

I hear you :slightly_smiling_face:, but my point was that if something is broken in this area, there is no way to fix it, because it does not exist any more. Windows 3.1 still has bugs too!

The UI editor in Paper UI is not so good. Scripted automation is very good. Scripted automation with the helper libraries is great. Soon, these will be available to install through Paper UI…

But you can manually install too…

https://openhab-scripters.github.io/openhab-helper-libraries/Getting%20Started/Installation.html

If you post a rule, I will migrate it to Jython for you!

Agreed. It’s not going to run in June, except on Sundays.
Is there a problem with this rule?

Similarly, rule 2 I would expect to run only at 07:30 every day in June.
Your log entry shows this.

Can you tell us what you expected to happen instead?

OH2.5 is the current recommended version, no cron changes should have occurred, DSL rules are the most mature available on 2.5.

1 Like

Duh! Well, that’s embarrassing :blush: No wonder I just started noticing it. It’s just June 8… and it worked in May :wink:

2 Likes

Lockdown fever :wink:

1 Like