Hi all
I’m using the integration of my grabage collector to acquire dates of collection dates. These update correctly and display correctly. However, I try to use an template to convert it to how many days from now the collection of garbage is. I’m pretty new to templating and home assistant. I’m using the template posted here: Template Guide: Days away from calendar event
My configuration file contains the lines below in the sensors section:
- platform: time_date
display_options:
- 'date'
- platform: template
sensors:
grijze_bak:
friendly_name: Grijze bak
entity_id: sensor.date
icon_template: 'mdi:delete-empty'
value_template: >
{% set midnight = now().replace(hour=0, minute=0, second=0, microsecond=0).timestamp() %}
{% set event = states('sensor.non_recyclable_waste_pickup') | as_timestamp %}
{% set delta = ((event - midnight) // 86400) | int %}
{% if delta == 0 %}
Vandaag
{% elif delta == 1 %}
Morgen
{% elif delta == 2 %}
Overmorgen
{% else %}
Over {{ delta }} dagen
{% endif %}
If I reboot home assistant it updates correctly. However, it does not update on midnight. I though it would update on midnight because I incorporte the time_date platform with sensor.date as entity_id within my template. I have 3 comparable templates directly after the these for the different types of garbage. All of these update on reboot but not midnight.
Can anyone help me find out what I’m doing wrong?