Hi guys, i tried to make a rule that will turn off my lights outside my house at midnight for every night. But it didn’t worked out, as the lights where still on when I came down the next day. Looking in the logs, there was no sign that the rule was executed. This is the rule:
rule “Luifelverlichting uit” //luifelverlichting uit
Time cron “0 0 * * *”
The indents don’t look right but that’s just how my text is converted and I don’t know how to fix that…
I know can adjust the “when” to Time is midnight, but I wanna know what’s wrong with this, so that I can use it for other times as well.
Log files around midnight:
2020-06-16 23:14:56.016 [vent.ItemStateChangedEvent] - Temperature changed from 16.54 to 16.67
2020-06-17 00:00:30.872 [vent.ItemStateChangedEvent] - Sunrise_Time changed from 2020-06-16T05:23:00.000+0200 to 2020-06-17T05:23:00.000+0200
2020-06-17 00:00:30.879 [vent.ItemStateChangedEvent] - Sunset_Time changed from 2020-06-16T22:00:00.000+0200 to 2020-06-17T22:00:00.000+0200
2020-06-17 00:09:55.983 [vent.ItemStateChangedEvent] - Temperature changed from 16.67 to 16.40
thanks for your responds, however I don’t know exactly what you mean. In the events.log should be like a trigger for the rule right? And since it’s not in there, I assume that the problem is in the cron time right?
This should be Time cron "10 0 0 * * ? *" as @Jim_Verspuij mentioned (be aware of the extra *), in case of 10 seconds after midnight, otherwise it should be Time cron "0 0 0 * * ? *"
On other option is to use Design Pattern: Time Of Day. It more advanced rule.
Time cron is using quartz cron (and this is a little bit different to crontab). The Time cron expression is:
Time cron "ss mm hh DD MM WW YYYY"
where YYYY is OPTIONAL. All other fields are mandatory.
ss -> Seconds
mm -> Minutes
hh -> Hours
DD -> Day of Month
MM -> Month (i.e. 1 to 12 or JAN to DEC)
WW -> Day of Week (i.e. 1 to 7 or SUN to SAT) You MUST use exactly one ? in your Time cron expresison. Either use it as Day of Week or as Day of Month. So, a trigger every day @ midnight would be either
Time cron "0 0 0 ? * *"
Time cron "0 0 0 * * ?"
as the year is optional.
Of course, you could write 0/60 instead of 0 for the Seconds or Minutes, as well as 1/1 for Day of Month or Month, or use an asterisk for the year…
The main point is: a questionmark is mandatory and quartz cron uses seconds.
Okay thanks! I shall implement it to make sure it will get into my logs.
Ah okay strange that the seconds where missing, cuz I used a website where you can generate your time in cron format… But anyhow, thanks for the support!
The questionmark is “This field is not set at all, so don’t care about”.
This is: You can’t build a Time cron expression which will only trigger, if it’s Friday, the 13th.
Of course you can trigger a rule on every 13th of a month and then check within the rule, if it’s Friday. But that is not a simple Time cron expression anymore.
Or in other words: you can specify either Day of Month or Day of Week, but not both at the same Time cron Expression.
To make that more clear to the user, you have to use the questionmark for one of the two fields.