Hey hey
Ive startet using HomeAssistant Local Calender instead of my Google one.
In a youtube video I learned how to trigger an event a specified time before a calendar entry starts.
Is it possible to trigger an event for an entry without time specified, too?
So I want to get a telegram message (via my bot), lets say on 9 am, if there is a calendar task for the whole day.
You could create an automation to fire at 9am with the condition that the calendar in question is ‘on’ with the ‘all_day’ flag.
Something like this maybe:
trigger:
- platform: time
at: "09:00:00"
condition:
- condition: template
value_template: |-
{{ state_attr('calendar.home_assistant', 'all_day') and
states('calendar.home_assistant') == 'on' }}
action:
- service: telegram_bot.send_message
data:
title: All day event notification
target: 12345678
message: "{{ state_attr('calendar.home_assistant', 'description') }}"
Obviously changing the calendar entity and telegram target to suit your environment.
Thanks! This works. I changed the bot message to show the message instead of the description.
But i get notified.
Problem is, if I have more than one “all day” task in my calendar, ill only get a message about the first one.
If I check the calendars attributes in developer tools I only see the first task either.
So I guess its not possible to show all tasks for today?
An All Day event starts at ‘00:00:00’.
Use a Calendar Trigger with a 9 hour positive offset and a Template Condition that checks if the value of the event’s all_day
property is true
and its summary
contains the text you want.
alias: Example
trigger:
- platform: calendar
event: start
entity_id: calendar.example
offset: '09:00:00'
condition:
- condition: template
value_template: >
{{ trigger.calendar_event.all_day and 'Garbage Day' in trigger.calendar_event.summary }}
action:
... etc ...
mode: parallel
EDIT
Based on allenporter’s advice (see below) I added the appropriate execution mode.
Calendar triggers work fine with multiple all day events at the same time (which is why they were created) to get around the limitation of the sensor attributes. From Calendar - Home Assistant make sure you are not using mode single
or it only sends you one event if multiple fire in parallel.
Thanks for your answers.
But I dont know how to get an action inside @123 's Code showing me what I want.
Is it possible to get some Telegram message like this:
“Today in Calendar”
- Task 1
- Task 2
- …
And did I get it correct, that I cant run this automation with the play button?
Because it then will show me all “all day tasks” for all my calendars?
Edit:
The reason for this is, that I want to set all entries from specific calendars to my shopping list (which I use as to do).
So on 9 am I want a telegram message for all my tasks in calendar, and I want them to appear on my shopping list.
I just installed version 2023.07 to get the calendar.list_events service.
This gives me all my events as I want.
But how to add them to a telegram message, or the todo?
Each event can have up to five properties: summary, description, start, end, location.
What exactly do you want to show in the telegram message?
The last example, in the Calendar documentation, demonstrates how to iterate through the response_variable and display each event’s start
and summary
.
There’s a more complex template example here. It’s a streamlined version of someone else’s work so it displays the response_variable’s events according to the user’s requirements.
Thanks for the link. Now I got it and created an (almost) working Automation, which looks as follows:
alias: AAAA Kalender GanztagesereignisseTest
description: ""
trigger: []
condition: []
action:
- service: calendar.list_events
data:
duration:
hours: 24
minutes: 0
seconds: 0
target:
entity_id: calendar.bestellen
response_variable: calendartasks
- service: telegram_bot.send_message
data:
title: Tasks today
message: >-
Your agenda for today: <p> {% for event in calendartasks.events %} {{
event.summary }}<br> {% endfor %} </p>
mode: parallel
max: 10
If I run this now, I see all my testtasks for tomorrow. (The entered settings are only for testing.
The only problem now is, that the text is not formatted. Those html tags (
and
) don’t format my text, but are shown inside the telegram message.
Did you manage to get the formating corrected, been after something like this for a while and this works great outside of the formating tags