diff -r ffc4b8aa824f -r 1f89da6511a9 thermferm/thermferm.c --- a/thermferm/thermferm.c Wed Apr 01 15:56:04 2015 +0200 +++ b/thermferm/thermferm.c Wed Apr 01 17:28:26 2015 +0200 @@ -1436,16 +1436,28 @@ if ((unit->heater_address || unit->cooler_address) && unit->fan_address) { /* * If there is a heater or cooler and we have a fan, turn fan on if - * cooling or heating. + * cooling or heating. The Fan has a start/stop delay. */ if ((unit->heater_address && unit->heater_state) || (unit->cooler_address && unit->cooler_state)) { - if (! unit->fan_state) - syslog(LOG_NOTICE, "Fan Off => On"); - unit->fan_state = 100; + if (unit->fan_wait < unit->fan_delay) { + unit->fan_wait++; + syslog(LOG_NOTICE, "fan_wait + %d/%d", unit->fan_wait, unit->fan_delay); + } else { + if (! unit->fan_state) { + syslog(LOG_NOTICE, "Fan Off => On"); + unit->fan_state = 100; + } + } } else { - if (unit->fan_state) - syslog(LOG_NOTICE, "Fan On => Off"); - unit->fan_state = 0; + if (unit->fan_wait > 0) { + unit->fan_wait--; + syslog(LOG_NOTICE, "fan_wait - %d/%d", unit->fan_wait, unit->fan_delay); + } else { + if (unit->fan_state) { + syslog(LOG_NOTICE, "Fan On => Off"); + unit->fan_state = 0; + } + } } device_out(unit->fan_address, unit->fan_state); } @@ -1454,8 +1466,8 @@ P_err = 0.0; unit->PID_iState = 0.0; unit->PID_dState = 0.0; - } - } + } /* fridge beer or profile mode */ + } /* for units */ #ifdef HAVE_WIRINGPI_H piLock(LOCK_MENU);