No, this configuration does not belong in sensor.yaml
. The current method for configuring template sensors, which allow triggers and actions, uses template
as its top-level key, not sensor
. You can either create a template:
block in your configuration.yaml
file, or use the !include
tag to have your template
integration-based configuration split to their own file(s)
Also, the available calendar services have been updated to address the issue of returning data from multiple calendars in one call. The service calendar.list_events
is being phased out and will be remove in 2024.6. Instead use calendar.get_events
.
template:
- trigger:
- platform: time_pattern
minutes: /1
action:
- service: calendar.list_events
data:
duration:
hours: 72
minutes: 0
seconds: 0
start_date_time: "{{ today_at() }}"
target:
entity_id:
- calendar.familie
- calendar.soraneu_gmail_com
- calendar.viking1144_vk_gmail_com
response_variable: calendars
- variables:
ev_list: |
{% set ns = namespace(cal_events=[]) %}
{%- for key, value in calendars.items() %}
{%- for event in value.events %}
{%- set ns.cal_events = ns.cal_events + [event] %}
{%- endfor %}
{%- endfor %}
{{ ns.cal_events | sort(attribute='start') | list }}
sensor:
- name: Calendar Scheduled Events
unique_id: calendar_scheduled_events
state: "{{ ev_list | count }}"
attributes:
scheduled_events: "{{ ev_list }}"
icon: mdi:calendar'