making my first steps with template binary sensor. I have to Zigbee Thermometers, and I want to show “heat”, when one of the temperatures is more then 2 degrees above the other.
Here the template:
name: "Heizkörper Garderobe"
unique_id: "HK-Garderobe"
device_class: "heat"
state: >
{% set t1 = states('sensor.lumi_lumi_sens_e3e98705_temperature') | int %}
{% set t2 = states('sensor.lumi_lumi_sens_temperature') | int %}
{{ t1 - (t2 + 2) }}
But this shows almost always “heat”, but this is not what I expect.
It seems that it schows “cold” only when the Difference is exactly 0.0 .
What do I wrong here?
BTW: If I modify the sensor to:
Binary sensor templates are required to resolve to true or false. Your fist template resolves to a number, when this number is 0 it is interpreted as false.
Your second attempt has so much wrong with it that I gave up listing the issues.
Sorry for being annoying. I had checked that. Nevertheless, the display is not correct. It should display “normal” between 0:30 and 6:30 and from 13:30 (approximately), but not “heat”. Maybe this is also due to the display in Lovelace, or the way Home Assistant works internally. In any case, the two thermometers send updates at different times.