first of all, please be gently with me - cause im pretty new to this HA
How do i count and display number of events in local calendar in a template
can someone please help me with this?
I just want to display a number on how many events and tasks for today…
So i can use it in a notification on my mobile.
“You have 3 events and 2 task in your calendar today”…
i have search the web, but can’t find anything that does this for me…
There’s no easy way to get this information into a template sensor currently. You can get this information in a notification without a template sensor.
Apologies for bringing up an old thread, but I’m trying to do the same, but I’m struggling with the first block of code… is that an automation or a script?
I’ve added the code to both of those but when I run the second block of code as a script, I keep getting “UndefinedError: ‘calander’ is undefined”.
I’ve also tried to rename instances of calander to my local calander entity, but with the same ressult.
I’d appreciate any additional guidance that you could provide.
Thanks in advance!
Sorry to dig up an old topic, but when I try the code you gave @petro , it throws an error : Message malformed: extra keys not allowed @ data[‘calendar_events_today’]
Hi Petro, I am updating my automation at the moment which is close to 100% working, the only issue I have is trying to imbed a count events. I used the config in this thread which I presume should have worked however the example is a script not an automation, so does that mean that {{ agenda.events | count }} cannot be used in an automation, as it seems to not produce the expected result (always 0) even though the automation lists the events? The automation is below - dont take any notice of the time pattern only for testing.
alias: Garys Agenda test
description: ""
triggers:
- seconds: "1"
trigger: time_pattern
enabled: false
conditions: []
actions:
- action: calendar.get_events
metadata: {}
data:
duration:
hours: 24
minutes: 0
seconds: 0
target:
entity_id: calendar.wilkinson_business_gmail_com
response_variable: garys_agenda_2
- action: notify.homeassistant_gw_gmail_com
data:
title: Daily agenda for {{ now().date() }}
target: [email protected]
message: >-
Gary; you have {{ garys_agenda_2.events | count }} events in your agenda:<BR>
{% for event in
garys_agenda_2["calendar.wilkinson_business_gmail_com"]["events"] %}
{%- set start = event.start | as_datetime | as_local -%} {{ ['Today',
'Tomorrow'][(start.date() - now().date()).days] }}, at {{
start.strftime("%I:%M %p") }}, {{ event.summary }}<BR> {% endfor %}
enabled: true