EDIT: TURNS OUT IT WAS A WHITESPACE ISSUE…**
Hi, I’m fairly new to home assistant and I’m trying to set up a template sensor for next garbage collection day but somehow the sensor value is “unknown”. What am I doing wrong?
template:
- sensor:
- name: "Garbage collection"
state: >
{% set garbage = namespace(next_pickup=now()) %}
{% for day in range(7) %}
{% set tempDate = now() + timedelta(days=day) %}
{% if tempDate.weekday() == 2 and tempDate.isocalendar()[1] % 2 == 1 %}
{% set garbage.next_pickup = tempDate %}
{% endif %}
{% endfor %}
{## THE NEXT LINE IS NOT REGISTERED AS VALUE ##}}
{{ garbage.next_pickup.strftime('%d.%m.%Y') }}
Why is this not set as the value: {{ garbage.next_pickup.strftime(‘%d.%m.%Y’) }}
The code should loop for next 7 days and find next odd week wednesday. It’s rendering correctly in template editor inside HA…