Next holiday sensor

I have some programmable holiday lights using an outdoor neopixel and a esp8266 so I needed a way to detect the next holiday to change the color scheme automatically. So this morning I just pounded out this custom component sensor that just tells you the next upcoming holiday.

It’s based on the same python holiday component that the built-in workday sensor is made with so maybe I should try to add this capability to that sensor or something.

Will update the readme to detail the config options soon.

5 Likes

Hey there. I liked your job, but cannot understand what I should do to install this component on my HA. Can u help me?

1 Like

go to the github link above and copy the “next_holiday” folder and all of its contents into your custom_components folder in your config directory.

restart HA.

add the example sensor code (modified as necessary for your locale) to your “sensor:” section of configuration.yaml.

restart HA.

2 Likes

mesmerizing! tks for the answer, infinity rsr

2 Likes

This is a custom component and you can put it in a folder called custom_components that would be in the same dir as your main configuration.yaml file. So for example, my configuration.yaml is in /home/homeassistant/.homeassistant and so this component’s files are in /home/homeassistant/.homeassistant/custom_components/next_holiday

I can probably try to make this HACS compatible to make it easier if desired.

EDIT: OOPS I see this has been answered above. Sorry about the overlap. JINX

3 Likes

thanks, no problem man… I like aviation and the redundancy it preaches on planes, that is, the more redundant when it comes to information I don’t know, the better :smile: )

10 out 10 bro

I created a new template sensor call is_holiday_today

- platform: template
  sensors:
    is_holiday_today:
      friendly_name: Holiday Today
      value_template: >
        {%- if  state_attr("states.sensor.next_holiday", "today_is_holiday") == true %}
        on
        {%- else %}
        off
        {%- endif %}

when doing the next code change what
about get the code to create that sensor

now I can put that in automations as a trigger

1 Like

Isn’t that built in?

Also are people familiar with the workday integration?

1 Like

Great job! Looking forward to installing it with HACS!

Workday is binary and only tells you if a given day is a holiday or not.

1 Like

I just added the HACS metadata so I think it should be able to be installed but I have not tested it with HACS yet. Let me know if it works.

3 Likes

So is @myle’s

Thanks for doing that! I was able to install it through HACS and it’s working great!

I usually only install custom components through HACS so it’s easier to maintain in case there are breaking changes with Home Assistant in the future :smiley:

2 Likes

Ah, right, didn’t realize you were answering him.
Indeed that sensor is just reproducing the builtin workday, basically.

Sorry you are right, I didn’t make that plain.

Makes sense, thanks for the feedback. Glad it works.

So I made something like this using templates, one issue I ran into is that I would jump to the next holiday on the day of a current holiday, making automations useless. Is that what you’re doing here (haven’t looked at the code)

I anticipated that. The sensor state will remain on the holiday until the day after the holiday. So it’s more of a ‘next or current’ holiday sensor.

Relevant code here.

2 Likes

Does the sensor only show Holidays up to this year? Is it possible to show whatever python holiday has for next year as well?

Edit:

 
 ​        ​if​ ​next_holiday_date​ ​is​ ​None​: 
 ​            ​# lookahead into the next year 
 ​            ​holiday_data​.​update​(​_load_holidays​(​today​.​year​ ​+​ ​1​, ​self​.​_config​)) 
 ​            ​next_holiday_date​ ​=​ ​_find_next_holiday​(​today​, ​holiday_data​)

Would it be possible for us to pass in a config, eg if next holiday has only 3 in the list, start pulling from next year?

1 Like

Sure that’s totally doable. As you found we already do lookahead into the next year if there are no future holidays in the current year. But making that configurable is a great idea. Thanks for the suggestion.