At rule trigger "Time based", Day-of-Week field seems to be interpreted incorrectly


I generated a rule using this Time based Trigger:

    Time cron "0 0 7 ? * 2-6 *" // every weekday at 07:00

All openHab documents says: 1= Sunday, …
But my rule was executed last Saturday (which should be not!) and was not executed this Monday.
So it seems the numbers starts with 1= Monday.

Can anyone confirm, that this is an issue or am I wrong?

My configuration is:
openHab 3.3.0
Linux Ubuntu 20.04

0 (and 7) should be Sunday, 1 Monday etc. Can you point to where in the documentation it says otherwise? That will have to be corrected.

If have seen at Tutorial 6, which is referred by

specified as values between 1 and 7 (1 = Sunday) or by using the strings SUN, MON, TUE, WED, THU, FRI and SAT.

Additionally this expression is generated by (Free Online Cron Expression Generator and Describer -, which is referred by

Another thing is: When I specify 0-5, the rule has errors:

java.lang.IllegalArgumentException: Value too small in range in cron expression ‘0 0 7 ? * 0-5 *’ in field ‘DayOfWeek’: value 0, minimum: 1

Then the cron handler in OH seems to deviate from the unix standard in this regard. Just created a test rule (via the UI) and for me it works when using 2 as Monday, (the UI, however, says it should run on Tuesdays)

Anyway, could you try to use the weekday names instead and see if that works?

 Time cron "0 0 7 ? * MON-FRI *" // every weekday at 07:00

Using string literals (instead of numbers) works fine :+1:

But in my opinion, the documentation on using numbers could be updated.

Thanks for your help!

Could it be the case, that the start of the week is depending on your local and therefore it can be different on each installation?

I only know this from other software where start of the week will be different e.g. us english has Sunday to Saturday week but uk English, fr or de have Monday to Sunday as a week

It is different. It is Quartz cron which has a different specification.



1 Like