Automation During Date Range

If anyone wants to have a bunch of binary sensor entities for common date evaluations, just add these to your templates YAML.

    # Months
    - name: Is January
      state: >
        {{ now().month == 1 }}

    - name: Is February
      state: >
        {{ now().month == 2 }}

    - name: Is March
      state: >
        {{ now().month == 3 }}

    - name: Is April
      state: >
        {{ now().month == 4 }}

    - name: Is May
      state: >
        {{ now().month == 5 }}

    - name: Is June
      state: >
        {{ now().month == 6 }}

    - name: Is July
      state: >
        {{ now().month == 7 }}

    - name: Is August
      state: >
        {{ now().month == 8 }}

    - name: Is September
      state: >
        {{ now().month == 9 }}

    - name: Is October
      state: >
        {{ now().month == 10 }}

    - name: Is November
      state: >
        {{ now().month == 11 }}

    - name: Is December
      state: >
        {{ now().month == 12 }}

    # Days of Week
    - name: Is Monday
      state: >
        {{ now().isoweekday() == 1 }}

    - name: Is Tuesday
      state: >
        {{ now().isoweekday() == 2 }}

    - name: Is Wednesday
      state: >
        {{ now().isoweekday() == 3 }}

    - name: Is Thursday
      state: >
        {{ now().isoweekday() == 4 }}

    - name: Is Friday
      state: >
        {{ now().isoweekday() == 5 }}

    - name: Is Saturday
      state: >
        {{ now().isoweekday() == 6 }}

    - name: Is Sunday
      state: >
        {{ now().isoweekday() == 7 }}

    # Special Days
    - name: Is First Day of Month
      state: >
        {{ now().day == 1 }}

    - name: Is 15th Day of Month
      state: >
        {{ now().day == 15 }}

    - name: Is Last Day of Month # Credit: https://stackoverflow.com/a/13565185
      state: >
        {%- set next_month = now().replace(day=28) + timedelta(days=4) -%}
        {%- set last_day = next_month - timedelta(days=next_month.day) -%}
        {{ last_day == now().day }}

    # Holidays
    - name: Is New Years Day
      state: >
        {{ now().month == 1 and now().day == 1 }}

    - name: Is Groundhogs Day
      state: >
        {{ now().month == 2 and now().day == 2 }}

    - name: Is Valentines Day
      state: >
        {{ now().month == 2 and now().day == 14 }}

    - name: Is April Fools Day
      state: >
        {{ now().month == 4 and now().day == 1 }}

    - name: Is Earth Day
      state: >
        {{ now().month == 4 and now().day == 22 }}

    - name: Is May Day
      state: >
        {{ now().month == 5 and now().day == 1 }}

    - name: Is Cinco De Mayo
      state: >
        {{ now().month == 5 and now().day == 5 }}

    - name: Is Flag Day
      state: >
        {{ now().month == 6 and now().day == 14 }}

    - name: Is Juneteenth
      state: >
        {{ now().month == 6 and now().day == 19 }}

    - name: Is Independence Day
      state: >
        {{ now().month == 7 and now().day == 4 }}

    - name: Is Veterans Day
      state: >
        {{ now().month == 11 and now().day == 11 }}

    - name: Is Christmas
      state: >
        {{ now().month == 12 and now().day == 25 }}

    - name: Is New Years Eve
      state: >
        {{ now().month == 12 and now().day == 31 }}
2 Likes