Hello,
Does anyone know of a way to set an automation to run on the (for example) 1st Saturday of the month?
I know this can be done by day weekly but that’s too frequently.
Thanks,
Hello,
Does anyone know of a way to set an automation to run on the (for example) 1st Saturday of the month?
I know this can be done by day weekly but that’s too frequently.
Thanks,
You could use a template trigger:
{{ now().isoweekday() == 6 and now().day < 8 }}
Thanks. Where does that coding go? Sorry I’m not very familiar.
In the automation trigger section choose ‘template’ and copy the code into the field.
Awesome & thank you. So that I can learn more can you tell me what it means (how to read it) so that I can learn more about how you came up with that?
I’m not aware of any other trigger platform that could express “1st Saturday”. Sure, you could create a template sensor, but you would still use the template above.
The code has to come true to trigger the automation.
If you copy {{ now().isoweekday() }}
into Developer Tools → Template, you get ‘1’. isoweekday counts the days of the week from 1 (Monday) to 7 (Sunday). Today is Monday, so you get ‘1’.
If you want Saturday to be the trigger, the template becomes true with {{ now().isoweekday() == 6 }}
.
{{ now().day }}
represents the days of the month. The 1st Saturday of a month should (if I am correct) be no later than the 7th day of a month.
All together, the code means ‘Today is Saturday and max. 7 days of this month have passed’.
I’ll reread that a few times but think I get it.
Thanks,
Don’t hesitate to ask.