Hi,
I try to get all whole-day calendar events of tomorrow. Here is my template code:
- trigger:
- platform: time_pattern
minutes: /1
action:
- service: calendar.get_events
data:
duration:
hours: 24
minutes: 0
seconds: 0
start_date_time: "{{ (today_at('00:00') + timedelta(days=1)).strftime('%Y-%m-%d %H:%M:%S') }}"
target:
entity_id:
- calendar.abfall
response_variable: scheduled_events_abfall
- variables:
all_events: >
{{ scheduled_events_abfall["calendar.abfall"].events }}
filtered_events_restmuelltonne: >
{{ scheduled_events_abfall["calendar.abfall"].events | selectattr('summary', 'search', 'Restmuelltonne', true) | list }}
filtered_events_biotonne: >
{{ scheduled_events_abfall["calendar.abfall"].events | selectattr('summary', 'search', 'Biotonne', true) | list }}
filtered_events_papiertonne: >
{{ scheduled_events_abfall["calendar.abfall"].events | selectattr('summary', 'search', 'Papiertonne', true) | list }}
filtered_events_gelbetonne: >
{{ scheduled_events_abfall["calendar.abfall"].events | selectattr('summary', 'search', 'Gelbe Tonne', true) | list }}
filtered_events_glas: >
{{ scheduled_events_abfall["calendar.abfall"].events | selectattr('summary', 'search', 'Glas', true) | list }}
sensor:
- name: Calendar Scheduled Events
unique_id: calendar_scheduled_events
state: "{{ all_events | count() }}"
attributes:
all_events: "{{ all_events }}"
filtered_events_restmuelltonne: "{{ filtered_events_restmuelltonne }}"
filtered_events_biotonne: "{{ filtered_events_biotonne }}"
filtered_events_papiertonne: "{{ filtered_events_papiertonne }}"
filtered_events_gelbetonne: "{{ filtered_events_gelbetonne }}"
filtered_events_glas: "{{ filtered_events_glas }}"
icon: mdi:calendar
- name: Calendar Restmuelltonne
unique_id: calendar_restmuelltonne
state: "{{ filtered_events_restmuelltonne | count() }}"
icon: mdi:calendar
- name: Calendar Biotonne
unique_id: calendar_biotonne
state: "{{ filtered_events_biotonne | count() }}"
icon: mdi:calendar
- name: Calendar Papiertonne
unique_id: calendar_papiertonne
state: "{{ filtered_events_papiertonne | count() }}"
icon: mdi:calendar
- name: Calendar Gelbe Tonne
unique_id: calendar_gelbetonne
state: "{{ filtered_events_gelbetonne | count() }}"
icon: mdi:calendar
- name: Calendar Glas
unique_id: calendar_glas
state: "{{ filtered_events_glas | count() }}"
icon: mdi:calendar
here is the sensor output:
all_events:
- start: '2024-01-12'
end: '2024-01-13'
summary: 'Restmuelltonne '
description: Leerungserinnerung
location: xxx
- start: '2024-01-13'
end: '2024-01-14'
summary: Biotonne
filtered_events_restmuelltonne:
- start: '2024-01-12'
end: '2024-01-13'
summary: 'Restmuelltonne '
description: Leerungserinnerung
location: xxx
filtered_events_biotonne:
- start: '2024-01-13'
end: '2024-01-14'
summary: Biotonne
filtered_events_papiertonne:
filtered_events_gelbetonne:
filtered_events_glas:
icon: mdi:calendar
friendly_name: Calendar Scheduled Events
In this example you can see that I also get the whole day event of today. but I want only the whole day event of tomorrow.
Any idea what I could do?