I’m putting together a template sensor that will tell me what bin needs to go out each week. Here’s the template I’ve got so far:
{% if (now().isocalendar().week % 2 == 0) and (now().isoweekday() == 3) and (now().hour() == 15) %}
Green Waste
{% elif (now().isocalendar().week % 2 == 1) and (now().isoweekday() == 3) and (now().hour() == 15) %}
Recycling
{% else %}
No Bin
{% endif %}
So basically if the week is an even week AND the day of the week is 3 (Wednesday) AND the hour is 3pm (15), then display “Green Waste”. If the week is an odd week, display “Recycling”. Otherwise, display “No Bin”
This works perfectly fine, but if I change it to this:
{% if (now().isocalendar().week % 2 == 0) and (now().isoweekday() == 4) and (now().hour() == 15) %}
Green Waste
{% elif (now().isocalendar().week % 2 == 1) and (now().isoweekday() == 4) and (now().hour() == 15) %}
Recycling
{% else %}
No Bin
{% endif %}
I get this error:
TypeError: 'int' object is not callable
The ONLY difference between the two, is that I’ve changed 3
(Wednesday) to 4
(Thursday)
What’s the go here? Is it because today is Thursday and that’s doing something weird?
3 posts - 2 participants