How to configure a Temperature treshold based on another temperature with delta

Team,
I need help, I have a temp sensor that I use to switch off a fan when temperature is “low”.
The issue is that I cannot simply define a number for Low as it will not work during the year.
In the room I have a thermostat I can read.
How can I switch off the fan when the temperature from the sensor is between thermostat temp - 5 and thermostat temp + 5?
I was not able to define a rule in the automations

thanks
M

I’ve found:

configuration.yaml

binary_sensor:
  - platform: template
    sensors:
      shp1_temp_in_range:
        friendly_name: "SHP1 Temperature in Range"
        value_template: >
          {% set cucina = states('sensor.c_cucina_temperature') | float(0) %}
          {% set shp1 = states('sensor.shp1_temperature') | float(0) %}
          {{ cucina - 5 <= shp1 <= cucina + 5 }}

That is the legacy Template Binary Sensor syntax which has been scheduled for full deprecation in 4 months, use the current syntax as shown in the Template integration docs.