Hi folks,
I’m going to make an automation to use TTS to pronounce my agenda (all upcoming events for today) built from google calendar events when I’m leaving home. I already configured google calendar integration but did not find how to make list of upconfing events… I want to get time and title of each event. Can you help me with that?
any ideas or implementations? would appreciate any help
I know its been a while, any luck with this? looking for the exact same thing but reading about it, it seems to only be possible to get next event but as the calendar view exists i´m sure there must be a way…
Have you tried the Atomic Calendar Revived with HACS Store?
I use this and its quite well formatted.
Seems to be purely a custom frontend card and not sure if that helps to get a list of entities from the calendar that i can create a for loop from unless i missed something in the documentation.
Took a while but finally figured out a way, turns out Google Gmail exposes a ical format that is hidden away in the settings.
In Gmail, go to Settings → my calendar settings → then the calender you want → calendar settings
scroll down to ‘Integrate Calendar’ where you will find the ical url,
Once i had the ical i could use the ical-sensor plugin and generate X amount of sensors for events and create a loop for those, only taking into account the events that are present in the generated list. Only thing i dident figure out was how to have a “not” in the if statement of the is_state.
Here i get all the events for the present day in my morning routine,
{% for i in range(0, 9) %}
{% if is_state('sensor.ical_christian_kalender_event_' + i|string,'unavailable') %}
{% elif as_timestamp(state_attr('sensor.ical_christian_kalender_event_' + i|string, "start"))|timestamp_custom('%-d')
== as_timestamp(now())|timestamp_custom('%-d') %}
Klockan
{{ as_timestamp(state_attr('sensor.ical_christian_kalender_event_' + i|string, "start")) | timestamp_custom('%H:%M') }}
{{ state_attr('sensor.ical_christian_kalender_event_' + i|string, "summary") }}
{% endif %}
{% endfor%}
That only works for some Google calendars, I have a family calendar and that does not generate a ical string. Anyone know how to get the events in another way?
Hello,
I’ve just found something that can fix the problem, for me the problem was with the birthday calendar with the script all calendar entries are simply copied into a separate calendar 1:1, I hope it helps you too
There is a feature request for this functionality.
If you are also interested in getting a calender event list, please vote for this feature: Calendar - new entitites that show a list of events with a certain scope
My use case is to show a list of upcoming events on a epaper display. I already tried several ICS/ICAL custom_components, like the one @FakeThinkpad suggested, however they all seem to have huge problems with reoccuring events (e.g. birthdays events show up every month instead once a year) - at least for Google Calenders.
I have some sort of workaround for this:
-
create a new helper “text_input” (i called it trash, as I use it for a push message to remind me to put the trash out the night before it gets collected) - the default content of the helper will be ‘unknown’
-
create an automation that populates this text helper with calendar entries 24 hours before happening
alias: Fill Trash Notification
description: ""
trigger:
- platform: calendar
event: start
offset: "-24:00:0"
entity_id: calendar.abfall
condition: []
action:
- service: input_text.set_value
data:
value: |
{% if states('input_text.trash') == 'unknown' %}
{{ trigger.calendar_event.summary }}
{% else %}
{{ states('input_text.trash') }}
{{ trigger.calendar_event.summary }}
{% endif %}
target:
entity_id: input_text.trash
mode: queued
max: 10
- create an automation that will send the notification and afterwards will reset the value of the helper to ‘unknown’
alias: Notify Trash
description: ""
trigger: []
condition: []
action:
- device_id: xxxxxxxxx
domain: mobile_app
type: notify
title: Abfall
message: "{{ states('input_text.trash') }}"
- service: input_text.set_value
data:
value: unknown
target:
entity_id: input_text.trash
mode: single
I know that the caveat of this is probably calendar entries that are added less than 24 hours in the future. You could try to change this with the negative offset. For me it works as the trash calendar entries are already present in my calendar for the whole year
Sounds like a great solution!
I tried to follow to the letter but,
text helper does not come
populated by my calendar events (which works fine), always returns “unknown”!
What am I doing wrong?
If you are using the UI try typing input_text
And you need to create the text helper first
Settings → Devices & Services → Helpers
Sure, and input_text correctly returns “unknown” text, later I get the notification from the second automation too! but it doesn’t populate with my calendar information even though I check the content and the activation period
can you post the yaml code of your first automation?
alias: LeggiCalendari
description: ""
trigger:
- platform: calendar
event: start
offset: "-24:0:0"
entity_id: calendar.XXX_gmail_com
condition: []
action:
- service: input_text.set_value
data:
value: |
{% if states('input_text.calendario') == 'nulla' %}
{{ trigger.calendar_event.summary }}
{% else %}
{{ states('input_text.calendario') }}
{{ trigger.calendar_event.summary }}
{% endif %}
target:
entity_id: input_text.calendario
mode: queued
max: 10
alias: "*NotificaCalendario"
description: ""
trigger: []
condition: []
action:
- device_id: fdf86c095d2ea1b9309b9e97cfefaaa0
domain: mobile_app
type: notify
title: Calendario
message: "{{ states('input_text.calendario') }}"
- service: input_text.set_value
data:
value: nulla
target:
entity_id: input_text.calendario
mode: single
Hmm… only differens i notices is the different field length. I have 255 configurered
Do you have a trace of your first automation?
And did you create a test event that is exactly 24 hours in teh future for the automation to trigger properly?
No trace of a first automation. I have created many Test events also with ( offset: “0:0:0”) which I display in the HA Calendar with my email but, the automation does not seem to recognize the trigger or, I’m doing something wrong… I will do some more tests
I don’t really know why the first automation does not trigger for you.
Mine triggered successfully this morning, as tomorrow there is a chopping place open from 9 to 12 am
It triggered excatly 24 hours before the calendar entry.
Keep in mind that if you have calendar entries for example at 8am tomorrow and you play around with your automation and have an offset af 24 hours the automation will not trigger anymore as its now less than 24 hours in teh future. The trigger only happens once at exactly the defined offset.
Cheers,
Ben
Hi !
Perhapps too late but Add Quotes works well for me
{% if states('input_text.trash') == 'unknown' %}
"{{ trigger.calendar_event.summary }}"
{% else %}
{{ states('input_text.trash') }}
"{{ trigger.calendar_event.summary }}"
{% endif %}
I receive this message with the first automation. How come?
"Errore nell’esecuzione dell’azione
Error rendering data template: UndefinedError: ‘trigger’ is undefined"