diff -r 9eaaba49450f -r b34a1b2421fb thermferm/server.c --- a/thermferm/server.c Thu Aug 07 22:06:18 2014 +0200 +++ b/thermferm/server.c Fri Aug 08 23:07:44 2014 +0200 @@ -1116,8 +1116,10 @@ /* Initialize log if the unit is turned on */ if ((unit->mode == UNITMODE_OFF) && (i != UNITMODE_OFF)) initlog(unit->name); + syslog(LOG_NOTICE, "Mode from %s to %s via web interface", UNITMODE[unit->mode], UNITMODE[i]); unit->mode = i; /* Allways turn everything off after a mode change */ + unit->PID_I_err = unit->PID_err_old = 0.0; unit->heater_state = unit->cooler_state = unit->fan_state = 0; device_out(unit->heater_address, unit->heater_state); device_out(unit->cooler_address, unit->cooler_state); @@ -1145,6 +1147,14 @@ unit->profile = xstrcpy(val); else unit->profile = NULL; + /* + * Reset all output devices + */ + unit->PID_I_err = unit->PID_err_old = 0.0; + unit->heater_state = unit->cooler_state = unit->fan_state = 0; + device_out(unit->heater_address, unit->heater_state); + device_out(unit->cooler_address, unit->cooler_state); + device_out(unit->fan_address, unit->fan_state); } } else if (val && (strcmp(kwd, (char *)"PROF_STATE") == 0)) {