📅 Calendar Add-On + some calendar designs

I made an add-on that gives you an other way of integrating caldav or google calendar data and working with that data in Home Assistant automations and cards: Hass calendar add-on on Github.

Unlike the standard calendar integration, this add-on will give you a sensor with your calendar data in stead of a binary sensor. Once set up you’ll see an entity like this for each calendar you add to the add-on configuration:

entity: sensor.my-calendar
state: 2
data:
  - startDate: '2022-01-08T20:00:00.000Z'
    endDate: '2022-01-08T23:30:00.000Z'
    summary: Event example one
    location: Some street, Some place
    label: 🎉 party-time
    year: '22'
    start_month: jan
    start_day: 8
    start_time: '21:00'
    end_month: jan
    end_day: 9
    end_time: '00:30'
  - startDate: '2022-01-14T17:30:00.000Z'
    endDate: '2022-01-14T20:30:00.000Z'
    summary: Event example two
    location: My house
    year: '22'
    start_month: jan
    start_day: 14
    start_time: '18:30'
    end_month: jan
    end_day: 14
    end_time: '21:30'
    recurring: true

With the raw data available like this you can then build automations on top of that.

I made some choices that fit my current needs that you need to be aware of if you´d start using this add-on as well:

  • the add-on will query your calendar(s) for all events from today until a chosen number of future days. Past events are not available in the sensor.
  • caldav ‘categories’ and google calendar ‘description’ fields will end up in the label field in the sensor

Support for recurring events can be improved, for now you’ll know an event is recurring by the boolean field recurring. Similarly there’s a boolean for whole_day events as well. I plan to work on improvements here and also provide a config option to include past events as well. But development will probably be slow as I have other projects to work on for now.

Some calendar designs

My main personal usage is in the front-end. The standard calendar panel in Home Assistant is already very nice, but with the data from the add-on you can build your own calendar lay-outs or include calendar-data in other cards with HA’s templating syntax.

For instance, I have this summary of upcoming events on my main dashboard:

This is built with a custom button card (the one card to rule them all). Card code on github. Credit: design inspiration is from this codepen.

Another design I made (still WIP) is for your typical 3 column family planner:

This too is a custom button card (card code on github). The label-fields from the data are used to mimic the stickers you often get with physical planners.

I’m not fully happy with the design yet, I’d be interested to see how others that are better at design would improve on this template. And functionally the possibility to switch months is still missing.

7 Likes

This really looks awesome, but cant it get working with my icloud caldav:/

Looked into it as I don’t use Apple calendar myself. Like usual Apple makes it quite hard for you to use it outside their ecosystem. If you didn’t do this already, you need to obtain your caldav url through the steps layed out in the highest voted answer here: caldav - How to sync ICloud Calendar? - Ask Ubuntu
And then also generate an app-specific password like explained there.

I tested in Postman and the requests my add-on makes work as expected then. But the xml-response you get from the icloud server is slightly different from the one I’m getting from GMX I see, which makes that indeed the events will not be loaded. I need to adapt my code to make it work. I’ll see if I can find time in one of the next weekends.

1 Like

The solution wasn’t that complicated, I pushed an update to Github that should improve compatibility for different caldav providers.
For your Apple icloud calendar, your calendarUrl should look like https://*******.icloud.com/{dsid}/calendars/{calendarName}/ (Don’t forget to include the trailing forward slash)

1 Like

Hey, thanks for your elaborated reply and i will definitively look into that =) this would be so awesome :slight_smile:

Edit: This solved the issue - i also had to start new calendars, because my old ones seemed not to work - now everything setup and running - thank you :*

Lil time in your addon, and it seems that the startDate of all my entries is about one day wrong (2/9/22 → 2/10/22). is there a way around?

Hiya…

I’m struggling to get this up and running on a Google calendar. I’ve followed most instructions with no problem(I think).
The step I’m unsure about is where you store the .json file on Ha, I had no folder named “share”. So I created 1 in the config directory and used that, I also copied the file to the config directory. These 2 options don’t appear to work, any pointers greatly appreciated :pray:

The easiest way would be to use the official Samba addon (install from addon-store in HA), this should expose the /share folder as a network folder. Just copy the file into the shared folder then.
I personally use ssh to connect to my HA install, the folder then shows up here in my case (supervised install on debian):
ksnip_20220201-161552

Did you change the locale from its default ‘nl’ setting in the config? My guess is this causes the issue.

Thanks Kris,

I’ve found the share folder now and copied the .json to that location, I’m a step further forward now but not quite there.

This is my config.

And this is the error.

I suspect I’ve made an error on the google side of things, I shall do some more tinkering In a bit :wink:

That could do the trick, changed it to de but will try out some. Thanks for your answer :slight_smile:

Edit: Still persisting - and is probably something with the icloud integration. its not for every event true, and for those events the endDate is correct and also start_day is correct and for recurring events start & endDate are correct - i dont get the point, sorry for bothering you with this. I

This probably happens because you have not yet shared your calendar with the service-account.
Give acces to the service-account client_email (it can be found inside the json file if you don´t remember) here in the calendar settings (screenshot shows dutch language, but you’ll be able to deduce I guess):

That fixed It … Thanks

Could very well be an issue with my code as well, I only have my own data to test against of course. Are you familiar with how to install an addon locally? I could then give you a version of the code that will log the data to the console.

How is it supposed to work with nextcloud? my config is:

calendarList:
  - calName: Events / Appointments and Birthdays
    calType: caldav
    locale: fr
    username: thorsten
    password: xxxxxxxxxxxxx
    caldavUrl: https://cloud-space.ddns.net/remote.php/dav

But logs only show:

[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
added 62 packages, and audited 63 packages in 7s
21 packages are looking for funding
  run `npm fund` for details
found 0 vulnerabilities```

may additional info: my password starts with a % and i put it in config like :password: '%%xxxxxx'

im sorry i never did this bevor, but if you have a website with a how-to i will try to get it working.Perhaps a easy fix would be to change the format of “start_month” to a more generic “02” instead of “Feb.”, with that i could imagine to build a sensor for the sensor:D

The information on how to install an addon locally is available in the developer docs: Tutorial: Making your first add-on | Home Assistant Developer Docs

But instead of creating a new hello_world folder in your local /addons folder you need to copy the files of my addon there. Easiest is to download my repo as a zipfile from github, then unpack the hass-addon-calendar folder to your local /addons folder.

Now delete index.js and rename indexWithExtraLogging.js to index.js.

Then follow step 2 of the tutorial. You don’t need the next steps or the other info pages.

To eliminate confusion uninstall the addon that you installed previously via my repository.

Now upon running the locally installed add-on the logs should show the raw data of your calendar. If the information there is too private you can send it to me via a direct message.

I have no nextcloud install to test against so I hope you can debug yourself what is going wrong.
The log you posted seems to indicate you didn’t wait long enough for the addon to query and post your caldavprovider. As explained in the docs it queries only every 30 minutes, so you might have to wait up to 30 minutes.

As for the password: in yaml the ’ ’ is not needed normally, though it could be that including them is accepted as well.

You could also try to follow the advice I gave Flipso about installing the addon locally with extra logging.

Earlier before updating the add-on I strangely had data in the sensor…after not … well I downgraded and will wait tomorrow if it fills up with my data again