I have looked through RM and I don't see this is possible, but I thought I would ask. I would like to create a rule that runs certain actions for the two times during the year when DST and Standard time change. It always occurs on the Sunday of the 1st week of November and the Sunday of the 2nd week in March. Am I right there is no way to detect these dates and use them as a trigger?
You may be able to use two cron expressions
0 3 1-7 11 0
That should be "At 03:00 AM, between day 1 and 7 of the month, and on Sunday, only in November"
0 3 8-14 3 0
That should "At 03:00 AM, between day 8 and 14 of the month, and on Sunday, only in March"
Just adjust the first 3 and 0 for the time on those days.
The above is a good idea--you can do pretty much any schedule with a cron string.
In your case, you could just add those two as periodic triggers. Except for the Hubitat scheduler (Quartz), I think you'd need a slightly different format. I tested these to work:
0 0 3 ? NOV 1#1 *
0 0 3 ? MAR 1#2 *
For added fun, I might also suggest replacing that first
0 with a random second between
59 in case your hub has a bunch of things scheduled at the exact top of the minute (probably not because it is generally recommended for apps that schedule things automatically to avoid this, so having one thing yourself probably won't hurt...especially just twice a year! But it can't hurt). The second number is the minute, so you could also make the second
1 if you wanted 3:01 AM, for example -- just a guess as to what time you might want, but this is a common choice since it exists exactly once in both cases.
I guess I need to read up on CRON strings. Thanks for the advice.
Just tacking on to the end of this - can I use this approach for figuring out holidays that fall on certain days of the month - for example Thanksgiving being the last Thursday of the month? Thanks.
I don’t know about the other holidays, but, in the specific case of Thanksgiving, you could trigger the rule on every Thursday in November, then have a conditional that tests if the current day plus 7 is greater than 30. If so, it’s the last Thursday in November.
Ingenious. I also have the holiday app running so I thought to check for the second holiday in November, the first being Veterans Day. I came from HomeSeer a while back and they had a nice series of modifiers that allowed you to test for specific day of the month, or last occurrence of a day in the month, etc. Was hoping that something else existed but the technique you laid out will do just fine. Thanks
Still running into some brick walls with this. I can get the date of the month into a variable - but it is a string. So I can't test it by adding 7 and checking if over 30. Been searching around but so far stumped on how to proceed?
Maybe a bit overkill for your use case but I maintain the Google Calendar/Task/Gmail search app and Google has a holiday calendar you can query. I use it for mailbox alerts to notify if there is a holiday for example along with many other use cases:
This was actually part of what the cron string was that were provided above. Cron has the ability to say "between these days" in this month. So with the right cron string it will do this with no math needed.
Ok, you have the date as a string in stringDate. Here are the actions, etc, before running the rule:
The magic conversion happens on the first line.
Here is what happens after running the actions:
Thanks I installed this and use Veterans Day to test it. Works great. Just need to convert all of my holiday switches over to this and will be good to go. And then will look into the other capabilities. We use iCloud calendars in the house as all apple but will look to sync them and can have some fun.
Thanksgiving is the fourth Thursday in November. It's usually the last Thursday, but this November 2023 (this year) has five Thursdays.
You can still use a condition to check if the date is between 22-28, though.