Create calendar with same holiday date every year as binary_sensor? (perpetual calendar)

Hi. In configuration.yaml I have several calendars as binary sensors working great, BUT having to introduce the complete date including year (‘YYYY-MM-DD’) in the “add holidays” values:

  • platform: workday
    name: calendar_1
    country: ES
    workdays: [mon, tue, wed, thu, fri]
    excludes: [sat, sun, holiday]
    add_holidays:
    • ‘2022-01-03’
    • ‘2022-07-05’

I wonder who to create a “perpetual” calendar that works with month and day “add_holidays” values but WITHOUT YEAR VALUE, so works regardless of the year number.
For example, Christmas day is an example of value that has the same month and day regardless the year number, so really there is no need to change each year the year value in the ‘add_holidays’:
Any ideas???

Thank you

Just enable calendar for holidays and sync it with HA.

https://support.google.com/calendar/answer/6084659?co=GENIE.Platform%3DAndroid&hl=en#zippy=%2Cadd-or-change-country-and-region-holidays

Thanks [w35l3y], but I wanted to do it without external apps like Google Calendar, this is, introducing the dates directly in HA

I use a trigger-based template sensor for various holidays:

Sensor Example
template:
  - trigger:
      - platform: state
        entity_id: input_button.update_holiday_sensors
      - platform: homeassistant
        event: start
      - platform: event
        event_type: event_template_reloaded
    sensor:
      - name: "New Years Day"
        unique_id: "37319374975705055206"
        state: >
          {%- set today = now().date() %}
          {% set new_years = today.replace(month=1, day=1) %}
          {% if new_years < now().date() %}
          {% set new_years = today.replace(month=1, day=1, year= (now().year + 1)) %}
          {% endif %}
          {{ new_years }}
        attributes:
          days_until: >
            {%- set today = now().date() %}
            {% set new_years = today.replace(month=1, day=1) %}
            {% if new_years < now().date() %}
            {% set new_years = today.replace(month=1, day=1, year= (now().year + 1)) %}
            {% endif %}
            {% set x = new_years|string %}
            {% set x = (((x|as_datetime|as_local).date() - now().date()).days)|int %}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"

It could be converted into a binary sensor:

template:
  - trigger:
      - platform: time
        at: "00:00:00"
      - platform: homeassistant
        event: start
      - platform: event
        event_type: event_template_reloaded
    binary_sensor:
      - name: "New Years Day"
        unique_id: "19374937327570505506"
        state: >
          {% set new_years = now().date().replace(month=1, day=1) %}
          {{ new_years == now().date() }}
        availability: "{{ now() is defined }}"
        attributes:
          days_until: >
            {%- set today = now().date() %}
            {% set new_years = today.replace(month=1, day=1) %}
            {% if new_years < now().date() %}
            {% set new_years = today.replace(month=1, day=1, year= (now().year + 1)) %}
            {% endif %}
            {% set x = new_years|string %}
            {% set x = (((x|as_datetime|as_local).date() - now().date()).days)|int %}
            {{ iif(x < 1, x + 365, x) }}

Another option is to host your own CalDav server through an add-on like Radicale (GitHub - Ulrar/hassio-addons: Repo for hassio addons).

The HACS holiday looks OK but I do not see a way to add things, like St. Patricks Day, Mardi Gras, Cinco De Mayo, etc.

Like the holidays generated by HA’s built-in Workday sensor, the Holidays custom integration is based on the Python Holidays library… there is no easy way to add custom holidays. If you need holidays that are not included in the Python library for you locale, your options are to use one of the calendar integrations or to use something like the template binary sensor I presented above.

1 Like

The new workday sensor makes this even worse. At least in YAML, we could copy and paste the dates and move on. The new interface is painfully obnoxious in maintaining unique holidays each year. Having and option to make a holiday perpetual would be awesome!

And at the same time, having the ability to IGNORE some holidays perpetually would also be awesome. Not all holidays on the default holiday list are observed as non-workdays. There needs to be a better interface to toggle holidays on/off the list and also add unique holidays to the list.

At the moment, the current configuration is more useless than useful until we can have better control over the holiday list this integration uses.