
CalDAV Calendar in Home Assistant with AI Alerts
Today a post that I like :-), we'll give Home Assistant access to our calendars, whatever use we give it, be personal calendars, Corporate, Dating, saints, Football matches… and then we'll create some automation, For what, in the morning when we wake up tell us the appointments of the day and of course when an appointment arrives, remind us.
In this document we will subscribe Home Assistant to some calendars that we already have, on a CalDAV server that we saw some time ago, called Radicale; We will of course be able to subscribe you to any other calendar service we use. Once we have access to the calendars we will be able to view them, Create appointments manually or with automations, as well as knowing the appointments among others. What I said, At the end of the post we will see an automation that 5 minutes before the appointment he will remind us of it through the smart home speakers, Also in a random way, since we will use the Ollama's AI to personalize the messages so that they are different each time. As well as a second automation that in the mornings when we arrive at the kitchen, apart from saying good morning in a different way every day, reminds us of the appointments we have during the day, fabulous 🙂
At Home Assistant we are going to “Settings” > “Devices and services”, and click on “+ Add Integration”, and we are looking for CAlDAV, we click on it.
It will ask us for the CalDAV URL of the calendar, as well as the credentials to be able to access it, Click on “Send”,
Perfect, Click on “Finish”,
Once registered, we will see them as entities,
As well as we will have a view of the calendars from the left menu,
We will take into account that calendars are synchronized every 15 minutes, If we want to force a sync, especially now to do some testing, Well, we'll go to the “Developer Tools” and from “Services”, we are looking for the 'Home Assistant ore Intgration service': Reload the configuration entry’ and in the objects we select the calendars that we are interested in refreshing, in case we add any quotes…
Automation notifies you of upcoming event
This is an automation that will notify all the speakers in the home if there is an appointment on any calendar in the 5 minutes, in such a case the AI will come into play and send a random message telling us that we have such an appointment and that we will not forget it, each time in a different way and without using repetitive phrases.
In automation, in the When, We will select the calendar object that we are interested in, indicating that it is at the beginning of the event and with 5 minutes in advance, This is how this automation will jump.
And what will he do, Well, several things, on the one hand, it will send Ollama's AI the prompt we want, that is, Be kind, to remind you (In this case) to Hector who has a date, in 5 minutes.
Metadata: {} date: agent_id: xxxxxxxxxxxxxxx: >- Please, generates a text for a notification that will be sent to the user's smartphone. You're a useful personal agent that generates text for the user. Your answers are helpful, Kind, Warm, Insightful. Your answers are not technical. The message you have to report is: That Hector has an appointment on the calendar within 5 minutes. The event is {{ trigger.calendar_event.summary }}. response_variable: Response enabled: True Action: conversation.process
The first action of processing will ask the AI and get an answer in one variable.
Metadata: {} date: cache: true media_player_entity_id: media_player.volumio_mpd message: "{{ Response.speech.plain.speech }}" Target: entity_id: tts.piper action: tts.speak
After a friendly alert sounded over the speakers at home, it will be Piper who will be in charge of transforming that text of the variable into an almost human voice over the loudspeakers.
Automation reads quotes of the day
And I use this other automation for when our home greets us in the morning, it depends on who arrives in the kitchen first, Well, apart from greeting you and telling you some information that may interest you, because we read you the appointments on the calendar that you will have throughout the day, indicating as always with the AI in a random way every day the sentences.
date: start_date_time: "{{ today_at('00:00').strftime('%Y-%m-%d %H:%M:%S') }}" end_date_time: "{{ today_at('23:59').strftime('%Y-%m-%d %H:%M:%S') }}" Target: entity_id: - calendar.calendario_hector_personal response_variable: my_agenda_hector action: calendar.get_events
We will create a first action that will read all the events in the indicated calendar, at that time; It will put them in a variable.
date: agent_id: 491350952DA2D957EBC0EB37DA8C24A2 Text: >- Please, generates a text for a notification that will be sent to the user's smartphone. You're a useful personal agent that generates text for the user. Your answers are helpful, Kind, Warm, Insightful. Your answers are not technical, You don't need to say hello. You have to remember the appointments that Hector has today on the calendar, What are they: {%- if my_agenda_hector['calendar.calendario_hector_personal'].Events %} {%- for event in my_agenda_hector['calendar.calendario_hector_personal'].Events %} {{ event.summary }} {% if event.start is defined %} at {{ as_timestamp(event.start)|timestamp_custom('%H:%M',True)}} {% else %} All Day {% endif %} {%- if event.descripton is defined %} - {{ event.description }} Details: {{ event.descripton }} {% Diff-%} {%- if event.location is defined %} At {{event.location }} {% endif -%} <Br> {%- End %} {%- else %} There are no appointments on the calendar today.{%- endif %} Sort from newest to least recent. Don't put double quotation marks. Your answer in Spanish. response_variable: Action response: conversation.process
Subsequently, a second service will take this data from the variable and we will pass it to Ollama's AI so that it can interpret and read it to us, make us a summary and tell us in a random way the events of the day.
Metadata: {} date: cache: true media_player_entity_id: media_player.volumio_mpd message: "{{ Response.speech.plain.speech }}" Target: entity_id: tts.piper enabled: True Action: tts.speak
And finally, with a third action that will take the AI-generated text and convert it to audio, In a human voice, and play it on all the speakers in the home.
I hope you liked it, A somewhat curious post on how to give more intelligence to the home and take shape, This post is an example with calendars, But if you think about it, you can surely use these automations for other things, I'll give you some idea 😉 I send you a hug, behave well and take care of yourselves!