How to automate fan in ceiling acting as ventilation/heat recovery?

Hi all

I’m relatively new to home assistant and would appreciate some tips.

I have home assistant running on a raspberry pi in my lounge and gpio pins connecting to a relay board in the ceiling which turns on and off a fan to pull air from the ceiling space into the house, and two DS18b20 thermometers, one in the lounge and one in the ceiling.

I would like to turn on the fan when there is heat to recover from the ceiling in winter (e.g. if the lounge is < 20 degrees and the ceiling is warmer), to help cool the house when trying to sleep in summer (e.g. if the lounge is > 21 degrees and the ceiling is cooler), and to help generally circulate air in the house to help reduce condensation on windows in winter. This is acting essentially like a heat recovery or domestic ventilation system.

I have the thermometers and switches all working well and showing in home assistant. I can manually toggle the fan and it works great, but I’ve had problems with the automation.

I’ve had most success using climate generic_thermostat, but I can’t find a way to have it read two thermometers and act like I would like it to. Is there a way to make it smarter or can anyone suggest a better way to automate it to suit my needs?

Thank you all very much in advance.

climate:
  - platform: generic_thermostat
    name: Heater
    heater: switch.a
    target_sensor: sensor.loungetemp
    target_temp: 25
    tolerance: 1
    min_cycle_duration:
      minutes: 1