I’ve seen and been given different seasonal templates. But I have no idea how they work even when studying them and couldn’t find a great example to learn either.
Is it possible to explain how to create a template that turns on the last Saturday of September and turns off the first Saturday of November?
I want to understand how to make my own and not rely on the goodness of others.
September has 30 days so the last 7 days of September is a date greater than 23. The last Saturday can occur during those final 7 days. Use now().day > 23
For example, if we do this, the template reports true for the two dates and false for every other date of the year.
{{ (now().month == 9 and now().day > 23 and now().isoweekday() == 6 ) or
(now().month == 11 and now().day < 8 and now().isweekday() == 6) }}
It’s important to understand that the explanation I provided was creating a template that tells you if the current date is the last Saturday of September. It doesn’t calculate and report the date of the last Saturday of September.
So if your goal is to determine if the current date is between the last Saturday of September and the first Saturday in November, that’s a completely different requirement. That’s what the Christmas Season sensor you have does and you may have noticed it’s more complicated; it calculates the starting and ending dates in order to determine if the current date is between them.
My ultimate goal is to have a sensor that shows me if it is currently between the last Saturday in September and the first Saturday in November so my Halloween lights turn on or off automatically.
The Christmas sensor above does the same basic thing, but for Saturday after Thanksgiving to first Saturday in January. But I have no idea how it works.
Your explaination of how to determine if a day is a certain day is extremely helpful for understanding the process. But I’m lost on how to combine it all into a single template representing the timeframe.
I already asked them a bunch of questions and they trailed off and stopped answering, plus it was like 6 months ago. I felt it awkward to cold message then. So I made a general post in the forum.