Create 2 different calendars for different automations to work or not

Hi. In configuration.yaml I have a calendar with my kids school calendar to do certain automations the days is “on”:
binary_sensor:
# School calendar 2020-2021:
- platform: workday
country: ES
workdays: [mon, tue, wed, thu, fri]
excludes: [sat, sun, holiday]
add_holidays:
- ‘2021-01-01’
- ‘2021-01-02’
Etc, etc.
Is it possible to create another different calendar with my working days, so when mine is “on” certain automations work, and my kids calendar is “on” another different automations will work?
Thank you

You can have multiple calendars.

I think I use 3 different ones.

Great, but how do you code them? Thank you

You can import your ical calendar file from a web based calendar (google/microsoft/etc.).

In my case I add vacation to my work calendar, this shows up in HA as a sensor.


In the attributes there is description and time and all that.

I’m using Hacs ical sensor but I use a code variant I found on the github page for the project which suited me better.
I’ll see if I can find it.

I think it’s the one found here https://github.com/tybritten/ical-sensor-homeassistant/issues/26 (sensor.zip)

Thank you very much for your answers. I´m afraid I´m not so advanced user. My target is having something that works OK like the one shown below, but twice:

binary_sensor:

School calendar 2020-2021:

  • platform: workday
    country: ES
    workdays: [mon, tue, wed, thu, fri]
    excludes: [sat, sun, holiday]
    add_holidays:
    • ‘2021-01-01’
    • ‘2021-01-02’

This is, another similar to the above one but with a different “add_holidays” list, so for certain automations it will use the holidays of the first list and for other automations the holidays of the second list (first list is the kids holidays and the second list will be the parents holidays, much shorter).
Thank you very much in advance

Just add one more then…
I don’t really see the problem here.

Instead of hardcoding the holidays in a workday_sensor I would prefer a real calendar which is easier to maintain.

I use several google calendars for that (Home Office, Office, Vacation,…) which I use as different conditions in my automation.

For example:
Before going to bed an automation checks if I work from the office tomorrow and I get a notifiation when my alarm clock isn’t set correctly for that because I worked from the Home Office before.

That is pretty much the setup I have.
I also have a notification that is sent on Sunday evening telling me what calendar events I have the following week

What you configured here is not a calendar, it’s only a workday sensor and you can’t have multiple as far as I know.
You should connect one of your calendars, e.g. a google calendar and link this to Home Assistant.

My problem is that I don´t know how to do it. If below the code that works, this is:

platform: workday
country: ES
workdays: [mon, tue, wed, thu, fri]
excludes: [sat, sun, holiday]
add_holidays:

  • ‘2021-01-01’
  • ‘2021-01-02’

I write for example the same code but with a different name (workday_2 for example), so to have another binary_sensor with different holidyas, it doesn´t work:

platform: workday_2
country: ES
workdays: [mon, tue, wed, thu, fri]
excludes: [sat, sun, holiday]
add_holidays:

  • ‘2021-01-01’
  • ‘2021-01-02’

That´s what I´m looking for, having 2 different workday sensors. How would you code the second one to have 2 different ones? I´ve tried changing the platform name from workday to workday_2, but it doesn´t work

I did not know you was limited to one.
But as Burningstone says, use at least one calendar.

I recommend two. It will be so much easier to manage later.
You can add title and description and not just a cryptic date a few months in the future.
And you don’t need to restart HA every time you change something.
You get a UI that you can configure it in.
You can set a time, not just date.

Do you need more benefits of calendars vs workday sensor?

I have setup 2 different workday sensors. The default mon-fri and a specific ‘schoolday’ that is tue-thu.

binary_sensor:
  - platform: workday
    name: workday-default
    country: US
    add_holidays:
      - '2022-12-24'
  - platform: workday
    name: schoolday-childsname
    country: US
    workdays: [tue, wed, thu]

Pull request created to include example on workday docs: