Hi, I try to do the same thing you propose here (“Days until X” sensors based on single local calendar) with one calendar who contain events but my sensors stay with and unknown status.
i try to understand but i don’t know how i can debug this in template tools
your help will be appreciate
Here my template :
template:
- trigger:
- platform: time
at: "00:00:00"
action:
- service: calendar.get_events
data:
start_date_time: "{{today_at()}}"
duration:
hours: 168
target:
entity_id: calendar.poubelles
response_variable: agenda
sensor:
- name: jours_poubelles_dechets
state: >
{% set midnight = today_at() %}
{% set event = agenda["calendar.poubelles"].events | selectattr('summary', 'search', 'Déchets') | map(attribute='start') | map('as_datetime') | first %}
{% set delta = (event - midnight).days %}
{{ delta }}
{% if delta == 0 %}
Aujourd'hui
{% elif delta == 1 %}
Demain
{% elif delta == 2 %}
Après Demain
{% else %}
dans {{ delta }} jours
{% endif %}
unit_of_measurement: "Days"
- name: jours_poubelles_recyclages
state: >
{% set midnight = today_at() %}
{% set event = agenda['calendar.poubelles'].events | selectattr('summary', 'search', 'Recyclage') | map(attribute='start') | map('as_datetime') | first %}
{% set delta = (event - midnight).days %}
{{ delta }}
{% if delta == 0 %}
Aujourd'hui
{% elif delta == 1 %}
Demain
{% elif delta == 2 %}
Après Demain
{% else %}
dans {{ delta }} jours
{% endif %}
unit_of_measurement: "Days"
Also when i try the service in Developper tools i see one event :