Next holiday sensor

Ok I have added and released a new optional global config option min_future_holidays that you can use for this.

Config example:

sensor:
  - platform: next_holiday
    min_future_holidays: 3
    sources: 
     - country: "USA"
       state: "WA"
       exclude:
         - "washington's birthday"
1 Like

This is pretty cool and useful for me, especially knowing when Thanksgiving is in the US. One question, though, in looking at the code and the result, it looks like you are examining the current year (i.e., Thanksgiving is showing up even though it has passed). I havenā€™t installed this yet, so maybe that was an old screenshot, but are you looking at a 12 month moving window or just the current year?

The holidays attribute includes all holidays of this and maybe next year. We do compute only ā€˜future holidaysā€™ as well (and choose the first as the state) but we donā€™t expose that information as its own attribute. Would just a list of future holidays be useful? What kind of use case might people have for that? Easy to add if we want.

Well, for me at least, having a moving 12 month window from perhaps 30 days back to 11 months future would be pretty good. My use-case is also somewhat for holiday lighting because knowing the day after thanksgiving means I know when my lights turn on automatically. Right now I have an input-datetime that I plug in the next day-after-thanksgiving and I generally set it around October.

There are other great use-cases for knowing future holidays, such as blocking out calendars for long weekends in HA or auto-planning vacations based on ā€œhey I take a road trip every Memorial Dayā€.

Thatā€™s a couple of thoughts.

Thank you for the quick implementation! Iā€™ll try it out over the Christmas holidays! :smiley:

It would be awesome if you could add the current holiday as an attribute to the workday sensor in Core.

I like this sensor, but i just wonder, if itā€™s possible to turn dates around? I mean: 2022-01-22 is USA date form, while in most od EU we use other way around, so it should be 22-01-2022, or even better with dots instead of dashes, like: 22.1.2022.
Any way to do it?

This sensor is great for major holidays but what about Halloween, St. Patricks Day, Valentines Day, etc? Is it possible to add to the holiday list? I used this sensor to automate my outdoor lights based on the upcoming/current holiday. It would be great if this sensor supported non-major holidays and/or if I could add to the list. Thanks!

Hi, I want to create a sensor template which should calculate the last WORKING day of the current month.
For that I need to exclude weekends and holidays. Workday integration is good for evaluation whether today(or day with specified offset from today) is a working day.
But I need to check whether multiple dates (in sequence with steps -1 from last day of the month) are holidays or not. Installation is based on HassOS so the installation of custom components is not so free.

Not going to happen by the looks of it Add Halloween to US Holiday Schedule Ā· Issue #714 Ā· dr-prodigy/python-holidays Ā· GitHub

In case anyone is interestedā€¦
This is how Iā€™m using this and Thank you by the way for making this!!! :slight_smile:

I created a sensor like this:

- platform: template
  sensors:
    holiday_time:
      friendly_name: Next upcoming holiday
      value_template: >
        {%- set next = state_attr("sensor.next_holiday", "days_until_next_holiday") -%}
        {% if state_attr("sensor.next_holiday", "today_is_holiday") == false %}
        {%- if next == 1 -%} There is {{ state_attr("sensor.next_holiday", "days_until_next_holiday")}} days until {{ states("sensor.next_holiday") }}
        {%- elif next > 1 -%} There are {{ state_attr("sensor.next_holiday", "days_until_next_holiday")}} days until {{ states("sensor.next_holiday") }}
        {%- endif -%}  
        {% else %}
        Today is {{ states("sensor.next_holiday")}}  
        {% endif %}

So in the front end I get this:
Capture

Just thought Iā€™d share.

4 Likes

Seems to work through HACS if I manually add the repo. If youā€™re bothered, then you can create a PR for HACS to have your repo added as default here: https://hacs.xyz/docs/publish/include/

One thing to note is that currently your README.md doesnā€™t currently pull through so you get this displayed, but Iā€™ve just created a PR which should fix that: Update hacs.json to render the README.md by Gadgit83 Ā· Pull Request #4 Ā· partofthething/next-holiday-sensor Ā· GitHub

Before:

After: image

Does anyone have any thoughts on how to use this sensor for custom holidays that donā€™t fall on the same date every year? I think I was able to come up with a workaround for Easter ā€“ adding Canada and the NYSE options as sources allows me to get Good Friday and Easter Monday as holidays. But it would be great to get holidays like Motherā€™s Day (the 2nd Sunday in May) or Fatherā€™s Day (the 3rd Sunday in June). I know the developers of the Python holiday package wonā€™t be adding non-official holidays, but Iā€™m wondering if thereā€™s a way to define these types of holidays manually.

As far as Iā€™m aware, the custom_holidays option only allows you to specify an absolute date. Does anyone know of a way to specify custom holidays like the ones above?

You could have a look at Webcal Guru