Hi,
I am most likely overlooking the obvious here. I have been using the waste_collection_schedule integration via HACS to keep track of the dates our bins get emptied on.
It uses template sensors to map the remaining days until collection to more readable states (0 days = “Today”, 1 day = “Tomorrow”, 2+ days = “in x days”).
After adding an input_boolean to indicate if I already placed the bins at the street to be emptied, I now also want to use this input_boolean to change the state of the sensor to “Prepared for emptying” (so my wife can easily check it on the wallpanel and remind me in case I forgot it ):
Note: I am comparing value.daysTo to 3 for easier testing, normally it would be compared to 0
- platform: waste_collection_schedule
name: "Restmüll"
value_template: >-
{% set rausgestellt = is_state('binary_sensor.mull_rausgestellt', 'on') %}
{% if value.daysTo == 3 and rausgestellt == True %}
Rausgestellt
{% elif value.daysTo == 3 %}
Heute
{% elif value.daysTo == 1 %}
Morgen
{% else %}
in {{value.daysTo}} Tagen
{% endif %}
types:
- Restabfall
My problem is that is_state(‘binary_sensor.mull_rausgestellt’, ‘on’) never evaluates to True, even though the dev tools clearly show that both the input_boolean and the binary_sensor (which is based in the input_boolean) are both set to on. So the state of the sensor always is Heute. If I change the condition to {% if value.daysTo == 3 and rausgestellt == False %} the sensor state changes to Rausgestellt.
Pasting this code to the template tool in the dev section everything works as expected:
There is also no difference if I use the input_boolean directly in the template instead of the binary_sensor.
So what am I missing here?