Template evaluation help

Hi,
Can someone help me why the below templates in snapshot at order no. 2 is returning Yes where as it should return No? I have also listed the values for individual components of template in order no. 3 & 4 and can not figure out problem with my second template. I am running Hassio version 0.79.3, any your help/ feedback is appreciated.

At a guess it is returning the strings True and False rather than the boolean.

Try

{% if is_state('sensor.biweekly_garbage_week_now' , 'True') and now().isoweekday() == states.input_number.biweekly_green_garbage_day_select.state|int %}

What you mentioned with that change it worked and you are right it is returning string but still not able to understand why the AND statement is returning Yes if the first condition is not returning binary True? Thanks for your prompt help.

It’s probably evaluating whether it’s getting a state, so the fact that it is receiving the string “false” is true. It would be false if no state was present.

Again, educated guess rather than knowledge.

Glad you’re sorted :+1:

This is what I used for my template:
'{% if states.sensor.biweekly_garbage_week_now.state == "True" and now().isoweekday() == states.input_number.biweekly_green_garbage_day_select.state | int %}Yes{% else %}No{% endif %}'

Once again thank you.

1 Like