I am using this (thanks petro!!):
When I tried to modify it to create a Halloween sensor, it returns back as True for today (November 17th)
# Is it the Halloween Season? (Last Saturday of September to first Saturday after Halloween)
halloween_season:
unique_id: halloween_season
friendly_name: Halloween Season
value_template: >
{%- set month, week, day = 9, 4, 5 %}
{%- set today = now().date() %}
{%- set temp = today.replace(month=month, day=1) %}
{%- set adjust = (day - temp.weekday()) % 7 %}
{%- set temp = temp + timedelta(days=adjust) %}
{%- set halloween1 = temp + timedelta(weeks = week - 1) %}
{%- set month, week, day = 11, 1, 5 %}
{%- set temp = today.replace(month=month, day=1) %}
{%- set adjust = (day - temp.weekday()) % 7 %}
{%- set temp = temp + timedelta(days=adjust) %}
{%- set halloween2 = temp + timedelta(weeks = week - 1) %}
{{ today < halloween2 or today > halloween1 }}
I tried to make one for Thanksgiving as well. But as the Halloween one is broken, I have to assume this one is as well
# Is it the Thanksgiving Season? (Thursday before Thanksgiving to Thanksgiving)
thanksgiving_season:
unique_id: thanksgiving_season
friendly_name: Thanksgiving Season
value_template: >
{%- set month, week, day = 11, 3, 3 %}
{%- set today = now().date() %}
{%- set temp = today.replace(month=month, day=1) %}
{%- set adjust = (day - temp.weekday()) % 7 %}
{%- set temp = temp + timedelta(days=adjust) %}
{%- set thanksgiving1 = temp + timedelta(weeks = week - 1) %}
{%- set month, week, day = 11, 4, 3 %}
{%- set temp = today.replace(month=month, day=1) %}
{%- set adjust = (day - temp.weekday()) % 7 %}
{%- set temp = temp + timedelta(days=adjust) %}
{%- set thanksgiving2 = temp + timedelta(weeks = week - 1) %}
{{ today < thanksgiving2 or today > thanksgiving1 }}
Can anyone help me solve this? I’d like to create a slew of sensors based on the Thanksgiving one that show a week before a holiday through the Holiday itself.