diff -r 18dd6eadba31 -r aad7789a40f2 thermferm/thermferm.c --- a/thermferm/thermferm.c Thu Feb 19 15:43:43 2015 +0100 +++ b/thermferm/thermferm.c Thu Feb 19 16:08:05 2015 +0100 @@ -1364,9 +1364,9 @@ /* * Simple temperature control */ - if (P_err < 0) { + if (P_err > 0) { Out = 100.0; - } else if (P_err > 0) { + } else if (P_err < 0) { Out = -100.0; } else { Out = 0.0; @@ -1412,13 +1412,13 @@ // } // unit->PID_dState = pv; - if (unit->heater_address) { + if (unit->heater_address && ! unit->cooler_state) { if (Out >= 1) { if (unit->heater_wait < unit->heater_delay) { unit->heater_wait++; syslog(LOG_NOTICE, "heater_wait + %d/%d", unit->heater_wait, unit->heater_delay); } else { - if (! unit->heater_state && ! unit->cooler_state) { + if (! unit->heater_state) { syslog(LOG_NOTICE, "Heater Off => On"); unit->heater_state = 100; } @@ -1436,7 +1436,7 @@ } device_out(unit->heater_address, unit->heater_state); } - if (unit->cooler_address) { + if (unit->cooler_address && ! unit->heater_state) { if (Out <= -1) { if (unit->cooler_wait < unit->cooler_delay) { unit->cooler_wait++;