[Scripting Automation Python] Once per month cron expression doesn't work

I have a rule that runs once per month on the first Monday of the month using the following cron expression:

@when("Time cron 0 0 0 ? * 2#1")

However I’m just now noticing that since I migrated this Rule from the Rules DSL version it has not run.

To debug the problem I’ve restored the Rules DSL version and changed the cron expression so it runs in a couple of minutes but still using the DAY#OCCURRENCE for the notation since that seems to be the source of the problem. So I have two versions of the Rule, one in each language and I confirm that the Rules DSL version does still fire and the Python one does not. So it appears to be a problem in either the Helper Library or in the Rule Engine itself.

As time allows I’ll look into at least the Helper Library code to see if I can find the source of the problem. I suspect it’s choking on the #.

I’m posting this here in the mean time in case this is something someone more familiar with the code has an idea.

EDIT: I don’t see anything in the Helper Library and I tried creating a managed rule and it too fails to trigger with this sort of cron trigger. So it would appear this problem is in the NGRE itself. Problem is I’m not sure which repo to post an issue to.

Rich, this looks to be an issue with the new scheduler. Another scheduler issue was reported in the forum, but nothing has been created in GH yet. I also have not had an opportunity to look at that one yet, but I also could not reproduce it. Issues for the scheduler should go into OHC.

I have too a role with a cron that don’t work and I can bet that it worked with the 2.4 stable release XD I past the cron, maybe it’s only my error

    rule "Alza Tapparelle"
when
        Time cron "0 0 09 1/1 * ? *"
then
        if (Fuori_Casa.state == ON && Annulla.state == OFF){
                                                           Tapparelle_ALL.sendCommand (30)
                                                           sendTelegram("bot1","Apertura Tapparelle in Corso")
                                                          }
        if (Fuori_Casa.state == ON && Annulla.state == ON){
                                                           Annulla.sendCommand (OFF)
                                                          }
end

it should move the rollershutter at 9 in the morning if I’m away.

This is unrelated to the above. Rules DSL, which this is, uses a different library to implement cron triggers than NGRE uses. The above applies to NGRE. You should open a different thread to cover this issue.

Though I do notice your expression is overly complex. It runs every day anyway so why add in the “starting on the first of the month”? I’d replace the 1/1 with a *.

1 Like

Just for the books: The expression "0 0 0 ? * MON#1" is an equivalent. Do you think it will work?

1 Like

I’ll give it a try…

Interesting, that worked. I’ll update the Issue with this information.

I see you are way ahead of me. Bit I did forget to come back here and post a link to the issue. Here it is:

I’m glad to see that I’m not just seeing things and I’m happy to see there is a work around until this gets fixed.

I think I found a solution for it. I submitted a bugfix (see PR 1159).

2 Likes