šŸ“… Calendar Add-On + some calendar designs

The repository-url is just that of the github repo: GitHub - kdw2060/hassio-addons: Repo for my Home Assistant add-ons

1 Like

I donā€™t understan what I must add in googleServiceAccountKeyfile?

Name of json file I created on google service-account?

Yes, the file-name goes in the config.

The file itself should be copied to the /share folder of Home Assistant.

1 Like

Can I fetch even description to sensor? How?

If youā€™re working with a google calendar then yes. You donā€™t need to do anything besides configuring the addon. The description will show up in the label field, like in my example in the start post.
I called it ā€˜labelā€™ because thatā€™s how I use it. I put an emoticon and one or two words in the description field in google calendar. But longer texts would simply show up in that field too.

1 Like

This Add-On looks awesome and exactly what I want. I keep running into a problemā€¦I have tried the Add-On both locally and through the traditional Add-On method, but I keep receiving this error:

Many thanks for any and all help!!

Your locale setting in the addon config seems to be wrong. For English you need to choose one of the variants that Moment offers (screenshot from momentjs.com)

THAT DID ITā€¦yay! Thank you SO very much. This Add-On is awesome. I was confused from what I saw on momentjs.com as the next line down shows English (United States)ā€¦

Nonethelessā€¦using en-gb did the trick. Thank you again so much.

NEW version published (0.200)

I pushed an update to Github. If you upgrade, make sure to edit your configuration as the configuration structure has changed.

The update mainly consists of improvements added by @cellerich:

  • Number of days to get events for is now a setting in stead of fixed 365 days
  • Frequency of querying events is now a setting in stead of fixed 30 minutes
  • Support for Baikal calldav calendars

Make sure to read the docs for more info on the changed config.

1 Like

Im sorry for my missed excerpt out of my caldav, but i used the time to get a bit used to your addon and i wanted to share my setup with all of you.

So one snippet out of my use case is that i combine two calendars dedicated to hold trash dates for different places (here lambsheim and frankenthal). Also i Filter all the events to only hold events in the upcoming week, search in there name for a matching trash type and give them a symbol and shortname.
I think this way i would be possible to get a neat integration of trashdays from different serviceholders via the exported trashlists - mine let them export directly to CalDav so this is seamlessly easy.

          {% set d1 = states.sensor.cal_frankenthal.state %}
          {% set d2 = states.sensor.cal_lambsheim.state %}
          {% set d3 = ((d1|int)+(d2|int)) %}
          {% set a = states.sensor.cal_frankenthal.attributes.data %}
          {% set b = states.sensor.cal_lambsheim.attributes.data %}
          {% set i = (a + b) | sort(attribute='endDate')%}
          {% for h in i%}
          {% set filter = (((as_timestamp(h.endDate) - as_timestamp(now())) / 60) | int)  %}
          {% if filter < 10080 %}
          {%- if  loop.first %}[ {% endif %} { "name": '{{loop.index}}',{%- if 'Frankenthal' in h.description -%}  "location": 'FT',{%- elif 'Lambsheim' in h.description -%}"location": 'LA',{% endif%}{%- if 'Altpapier' in h.description -%}  "symbol": 'šŸŸ¦', "trash": "Papier",{%- elif 'Schadstoff' in h.description -%}"symbol": 'šŸŸ„',"trash": "Schadstoffe",{%- elif 'Restabfall' in h.description -%}"symbol": 'ā¬›',"trash": "Restabfall",{%- elif 'Wertstoffe\, Bioabfall' in h.description -%}"symbol": 'šŸŸØšŸŸ«',"trash": "Papier & Plastik", {%- elif 'Abfuhr' in h.description -%}"symbol": 'šŸŸ«', "trash": "Bio",{%- endif %} "summary": '{{h.description}}', "minutes_till": {{((as_timestamp(h.endDate) - as_timestamp(now())) / 60) | int }},"state": {{d3}}, "start_time": '{{h.start_day}}.{{'%02d' % h.start_month_digits}}.{{h.year}} {{h.start_time}} Uhr', "time_z": '{{h.startDate[:-14]}} {{h.start_time}} - {{h.end_time}}' } {%- if not loop.last %},{% endif -%}
          {%- else -%}
          {%- endif %}
          {%- endfor %}]

after that i just put them in a markdowncard an let this be displayed as follows:

<b>Termine Frankenthal & Lambsheim</b>
| | |  
|:---:|:---|
{% for i in states.sensor.upcoming_events.attributes["object_lauft"] %}{% if i["summary"] == NULL %}
{%- else -%}
| {{i["symbol"]}} | <b>{{i["trash"]}} {{i["location"]}} |
| |{{ i["start_time"] }} | |
| |noch  {{ i["minutes_till"] }} Minuten | |
{%- endif %}
{% endfor %}

Bildschirmfoto 2022-05-13 um 09.05.40

Im still having issues with the startDate and endDate of the calendar integration - but this finally is my fault cause i hadnt had the time to export my log for you - sorry for that again.

Greetings=)

I do that, but what is the next step?

Frontend ā€¦

screenb

Hallo Bernd,

it sounds like youā€™re not familiar with sensor data, templating or the developer tools of Home Assistant. You will need to familiarize yourself with those concepts if you want to use your calendar data somewhere.

Your screenshot indicates that the addon is working properly, navigate to the dev-tools and search for the name you gave your calendar there. It should look something like this:

In my addon documentation Iā€™ve linked to the Home Assistant documentation about templating. You can test your templating syntax in the dev tools too, like this:

The post before yours in this thread by user Flipso contains an example of some more complex templating syntax inside a markdown card.

Personally Iā€™m not very fond of the jinja templating syntax that Home Assistant uses and prefer to write javascript for this instead. You can do this inside a custom button card. In my initial post in this thread I link to two example custom button cards.

Eitherway if youā€™re not familiar with scripting languages youā€™ll have a bit of a learning curve ahead Iā€™m afraid.

Hello, do recurring full day events work with that?

I would like an automation to behave differently depending on which full day event is active.

The default caldav integration is not able to detect recurring full day eventsā€¦

Recurring events will have the recurring: true attribute.

However I remember from testing with a birthday that I still needed to fix some things. I donā€™t remember exactly, but I think the year may be incorrect in the sensor data now if the event has been in your calendar for several years. Itā€™s on my to-do list to investigate and fix this sometime.

hi @EdwardEnglish, sorry my memory failed me, the recurring events attribute is currently only there for google calendar events, not for events from a caldav calendar. I do plan on adding support for recurring events, but canā€™t say when I will find time to work on it. I did start reading up on the documenation and having a look at examples. It seems like the most complex bit here will be calculating the current applicable date of a recurring event as the data gives you the initial date and a recurrence format, not a ready made list of future dates.

Hello @kdw2060
I try to setup your addon for my google calendar but I am struggling a bit. I have a few questions.
My config looks like this:

locale: de
fetchDays: 5
fetchCRON: '*/30 * * * *'
calendarList:
  - calName: Geburtstage
    calType: google
    calId: xxxxxxxxxxxxx
    googleServiceAccountKeyfile: google_credential.json

The log tells me the following:

23 packages are looking for funding
  run npm fund for details
found 0 vulnerabilities
Calendar(s) queried at: Wed Jul 13 2022 01:30:00 GMT+0200 (Central European Summer Time)
postEventsAllCalendars error: TypeError: Cannot read properties of undefined (reading 'length')
CRON-Task: Events posted to sensor(s) at: Wed Jul 13 2022 01:30:00 GMT+0200 (Central European Summer Time)
There was an error loading the gcal data: Error: No key or keyFile set.

So I guess this one ā€œgoogleServiceAccountKeyfileā€ is wrong.

I copied it to \share
Is the folder name needed for the attribute as well?

Then I have a question regarding the addon folder. There should be the data folder with the allFutureEvents.json.

I installed your addon (as well as all other installed addons) directly via the admin UI in Home assistant. When I go to \addons the folder is empty. There is no file or directory inside. So I am wondering if this was the right way to copy my credential files to the \share folder.

And I saw something that I need to provide my service account email to my calender and share the calender with this email. But I donā€™t know where do I get this service account email?

Your configuration looks good, no errors there as far as I can see (I cannot know if your calId is correct off course). The \share folder is not a subfolder of addons, itā€™s a seperate standard folder in the HA folder structure (see this earlier reply).

As the loading of the events failed itā€™s logical there is no allFutureEvents.json file yet.

The service-account email was presented to you when you made the service account, but is also visible inside the service-account json file. Just open it with a text editor and copy paste te e-mail. How to share a calendar with that e-mail adress is shown in this earlier reply.

I think you might not have placed the serviceaccount json file in the right folder and/or you didnā€™t share the calendar with the service-account e-mail adress.

@kdw2060
OK, I used a wrong json file.
I think I now have the correct file, but I am not able to retrieve events:

found 0 vulnerabilities
Previously stored events posted to sensor(s) at: Wed Jul 13 2022 12:28:49 GMT+0200 (Central European Summer Time)
postEventsAllCalendars error: TypeError: Cannot read properties of undefined (reading ā€˜lengthā€™)
Calendar(s) queried at: Wed Jul 13 2022 12:30:00 GMT+0200 (Central European Summer Time)
postEventsAllCalendars error: TypeError: Cannot read properties of undefined (reading ā€˜lengthā€™)
CRON-Task: Events posted to sensor(s) at: Wed Jul 13 2022 12:30:00 GMT+0200 (Central European Summer Time)
There was an error loading the gcal data: Error: Not Found

I think there was a typo in the calendar ID. Now there is just the error with Cannot read properties of undefined.

Calendar(s) queried at: Wed Jul 13 2022 12:40:00 GMT+0200 (Central European Summer Time)
postEventsAllCalendars error: TypeError: Cannot read properties of undefined (reading 'length')
CRON-Task: Events posted to sensor(s) at: Wed Jul 13 2022 12:40:00 GMT+0200 (Central European Summer Time)

But I donā€™t know what else can I do.

Is it correct, that it should show up under the entity: sensor.. So in my case sensor.Geburtstage ?

Ok, after a restart the sensor shows up. Thank you for your support

Hello, The baikal and caldav woking without plugin install? My Hass Calendar working in caldav mode whitout error, but the sensor data emply.
Thx