Wanted to send a little update and convert to American (Fahrenheit instead of Celsius) as well as update the code to utilize system monitor integration which is the current (as of 9/2025) integration that gives you CPU/processor temp and other system related stats. I believe the above and original code was related to common ways of adding CPU temp stats to your RPI through the config YAML file. Thats why it referenced “sensor.cpu_temperature” where mine below is “sensor.processor_temperature”. Play with the threshold values as you like as the cycling of the fan can be annoying to some. Thank you all above for the help though
switch:
- platform: rpi_gpio
switches:
- port: 14
name: "RPI Cooling Fan"
unique_id: "rpi_cooling_fan"
climate:
- platform: generic_thermostat
name: RPI Cooling Fan Controller
unique_id: rpi_cooling_fan_controller
heater: switch.rpi_cooling_fan
target_sensor: sensor.processor_temperature
min_temp: 86 #30C
max_temp: 176 #80C
ac_mode: true
target_temp: 110
cold_tolerance: 5
hot_tolerance: 5
min_cycle_duration:
seconds: 600
keep_alive:
minutes: 5
initial_hvac_mode: "cool"
Edit: Additional tips, you need the HACS integration “Raspberry Pi GPIO” installed for this to work. Make sure you are looking at the above comments related to how they determine what pin to use for fan control. I did some tuning based on the lowest temp i saw my CPU get with constant active cooling and the top temp i saw it get with passive cooling. I do think that maybe it would be better to PWM my fan to have constant cooling to just keep it steady as im seeing a 20F swing with these settings every 10 minutes. Chatgps said that its fine and i dont know if its true but im okay with finding that out as time goes. There is cons to temp swinging if the range is large and closer to max ratings. I will try to reply if i figure out PWM control.