ebnerjoh
(Johannes Ebner)
March 15, 2026, 4:33pm
1
Hi,
I am controlling my Roof Window with Home Assistant. If the outside temperature is 2 degrees higher then the inside temperature, then I am closing the Roof (to keep the heat out).
This worked the last summers but now I noticed that my binary sensor is not working anymore.
template:
- sensor:
- unit_of_measurement: °C
default_entity_id: sensor.temp_vergleich_vorraum_dach_3
state: '{{ states.sensor.vorraum_temperature_template.state | float - states.sensor.weather_weewx_outtemp_template.state
| float > 2 }}'
name: temp_vergleich_vorraum_dach_3
What I am doing wrong, or better said, what changed? Home Assistant is not showing any error.
Best Regards,
Johannes
ebnerjoh:
What I am doing wrong…?
Basically, you’ve included 3 failure points…
Using the state object method instead of the, recommended, states() function. The following warning has been in the docs for over 5 years:
Not providing defaults for the float filter .
Not providing an availability .
Some situations do not require both defaults and availability, but most situations will require at least one of them to be used to get reliable results.
While it’s not a technical error, you are also not using a binary sensor for binary output.
template:
- binary_sensor:
- default_entity_id: binary_sensor.temp_vergleich_vorraum_dach_3
state: |
{{ states('sensor.vorraum_temperature_template') | float -
states('sensor.weather_weewx_outtemp_template') | float > 2 }}
name: temp_vergleich_vorraum_dach_3
availability: |
{{ has_value('sensor.vorraum_temperature_template') and
has_value('sensor.weather_weewx_outtemp_template') }}
123
(Taras)
March 15, 2026, 6:11pm
3
Remove this:
ebnerjoh:
unit_of_measurement: °C
Your template reports true or false which is not a temperature value in degrees Celsius.
1 Like
ebnerjoh
(Johannes Ebner)
March 15, 2026, 6:13pm
4
Thanks,
I reworked it following:
template:
- binary_sensor:
- name: "temp_vergleich_vorraum_dach_3"
unique_id: "temp_vergleich_vorraum_dach_3"
state: >
{% set diff = (states('sensor.vorraum_temperature_template') | float(0)) - (states('sensor.weather_weewx_outtemp_template') | float(0)) %}
{{ diff | abs < 2 }}
Now It is working again.
Would still add availibility template
1 Like