Hi,
i have created a new sensor with templates.
If i check the cal with service get_events it shows me the entries.
But if i look at developer tools at states it show unavailable. I cant see errors in yaml. Please help…Can you give me a hint?
service: calendar.get_events
data:
duration:
hours: 450
minutes: 0
seconds: 0
start_date_time: "{{ today_at() }}"
target:
entity_id: calendar.arbeit
response_variable: scheduled_arbeit
Answer:
calendar.arbeit:
events:
- start: "2023-12-14T08:00:00+01:00"
end: "2023-12-14T09:00:00+01:00"
summary: Laurent
description: anniversaire
- start: "2023-12-15T08:00:00+01:00"
end: "2023-12-15T09:00:00+01:00"
summary: Camille
description: anniversaire
I call it from configuration.yaml with
template: !include template.yaml
My Sensor in template.yaml
- trigger:
- platform: time_pattern
seconds: "30"
- platform: event
event_type: event_template_reloaded
- action:
- service: calendar.get_events
data:
duration:
hours: 450
minutes: 0
seconds: 0
start_date_time: "{{ today_at() }}"
target:
entity_id: calendar.arbeit
response_variable: scheduled_event
- sensor:
- name: Calendar Scheduled Arbeit
unique_id: calendar_scheduled_Arbeit
state: "{{ scheduled_event['calendar.arbeit']['events'] | count() }}"
attributes:
scheduled_events: "{{ scheduled_event['calendar.arbeit']['events'] }}"
icon: mdi:calendar'