Create a sensor for holidays/workdays

Hi, I’m trying to create a sensor indicating if a given date is considered workday or holiday.
I would like to do this for two differen contries, Italy and US.
I created two binary sensors for both countries as below

Giorni lavorativi Italia

  • platform: workday
    country: IT
    name: “Giorni lavorativi Italia”
    workdays: [mon, tue, wed, thu, fri]
    excludes: [sat, sun, holiday]
    add_holidays:
    • 2021-12-24
    • 2021-12-31
      remove_holidays:
    • 2021-01-06
    • 2021-06-02
    • 2021-11-01

Giorni lavorativi USA

  • platform: workday
    country: US
    name: “Giorni lavorativi USA”
    workdays: [mon, tue, wed, thu, fri]
    excludes: [sat, sun, holiday]
    add_holidays:
    • 2021-01-18
    • 2021-02-15
    • 2021-04-02
    • 2021-05-31
    • 2021-07-05
    • 2021-09-06
    • 2021-11-25
    • 2021-12-24
      remove_holidays:

      I tried many ways to connect this sensor to input.date entity but non success. Anyone who has the same need or already accomplished this task?
      Thank you for your help

Please see the sticky post on how to correctly format code (point 11).

That aside, what do you mean by connect this sensor to input.date entity but non success?

Hi, basically what i want is an “input field” where to set a given date and a sensor that tells me if that date is a holiday or not (would be nice for two countries at the same time but I do not think is feasible).
I do have a sensor for for workadays but I DID NOT FIND how to relate this sensor to the input field.
As shown in the pictures I want to input a date in the input date field and get from the sensor if that date is a workday or not.

Lucky all those who were born masters

# Giorni lavorativi USA
  - platform: workday
    country: US
    name: "giorni lavorativi usa"
    workdays: [mon, tue, wed, thu, fri]
    excludes: [sat, sun, holiday]
    add_holidays:
      - 2021-01-18
      - 2021-02-15
      - 2021-04-02
      - 2021-05-31
      - 2021-07-05
      - 2021-09-06
      - 2021-11-25
      - 2021-12-24
    remove_holidays:

Here is the sensor in formatted text

1 Like

I use the hacs garbage collection for holidays. Here is my sanitized configuration.yaml code

#
# Use garbage collection to set events and holidays
#
garbage_collection:
  sensors:
  - name: Cleaning day
    frequency: even-weeks
    collection_days: thu
  - name: wife birthday
    frequency: annual
    date: '01/01'
  - name: my birthday
    frequency: annual
    date: '01/02'
  - name: daughter birthday
    frequency: annual
    date: '01/03'
  - name: Anniversary
    frequency: annual
    date: '01/04'
  - name: son birthday
    frequency: annual
    date: '01/05'
  - name: New Years Day
    frequency: annual
    date: '01/01'
  - name: Independence Day
    frequency: annual
    date: '07/04'
  - name: Halloween
    frequency: annual
    date: '10/31'
  - name: Christmas
    frequency: annual
    date: '12/25'
  - name: Watering Days #summer months 
    frequency: "weekly"
    collection_days: 
    - tue 
    - thu
    - sun
    first_month: "apr"
    last_month: "oct"
#

It creates all the entities and you can operate against them. I also use this for irrigation.

Hi, thank you for the hint; I’ll check if suitable for me. Actually what I’m trying to do is a calendar for the stock markets where opening and closing days vary year over year (easter, thanksgiving, etc.). Using the workday platform would automatically update most of them leaving just a few to be entered manually.