diff -r 5fd12d9f3f84 -r fd36bedab944 thermferm/thermferm.c --- a/thermferm/thermferm.c Mon Jun 26 13:58:11 2017 +0200 +++ b/thermferm/thermferm.c Mon Jun 26 19:21:07 2017 +0200 @@ -1240,7 +1240,7 @@ unit->air_temperature = temp; unit->air_state = 0; } else { - syslog(LOG_NOTICE, "deviation error deviation=%d, old=%d new=%d", deviation, unit->air_temperature, temp); + syslog(LOG_NOTICE, "deviation error air deviation=%d, old=%d new=%d", deviation, unit->air_temperature, temp); } } else if (rc == DEVPRESENT_ERROR) { unit->air_state = 1; @@ -1262,7 +1262,7 @@ unit->beer_temperature = temp; unit->beer_state = 0; } else { - syslog(LOG_NOTICE, "deviation error deviation=%d, old=%d new=%d", deviation, unit->beer_temperature, temp); + syslog(LOG_NOTICE, "deviation error beer deviation=%d, old=%d new=%d", deviation, unit->beer_temperature, temp); } } else if (rc == DEVPRESENT_ERROR) { unit->beer_state = 1; @@ -1271,6 +1271,28 @@ } } + if (unit->chiller_address) { + rc = device_in(unit->chiller_address, &temp); + if (rc == DEVPRESENT_YES) { + deviation = 40000; + if ((unit->chiller_temperature == 0) || + (unit->chiller_temperature && (temp > (int)unit->chiller_temperature - deviation) && (temp < ((int)unit->chiller_temperature + deviation)))) { + if (unit->chiller_temperature != temp) { + unit->mqtt_flag |= MQTT_FLAG_DATA; + pub_domoticz_temp(unit->chiller_idx, temp); + } + unit->chiller_temperature = temp; + unit->chiller_state = 0; + } else { + syslog(LOG_NOTICE, "deviation error chiller deviation=%d, old=%d new=%d", deviation, unit->chiller_temperature, temp); + } + } else if (rc == DEVPRESENT_ERROR) { + unit->chiller_state = 1; + } else { + unit->chiller_state = 2; + } + } + /* * Unit door state, default is closed. */ @@ -1629,6 +1651,14 @@ if ((unit->mode == UNITMODE_BEER) && ((unit->air_temperature / 1000.0) < (unit->PID_cool->Input - 5.0))) { unit->PID_cool->OutP = 0.0; } + /* + * Prevent cooling if we use a chiller and the chiller temperature is not low enough. + */ + if (unit->chiller_address && (unit->chiller_state == 0)) { + if ((unit->chiller_temperature / 1000.0) > (unit->PID_cool->Input - 1)) { + unit->PID_cool->OutP = 0.0; + } + } if (debug) fprintf(stdout, "Cool: sp=%.2f Input=%.2f iState=%.2f Err=%.2f Out=%.2f\n", unit->PID_cool->SetP, unit->PID_cool->Input, unit->PID_cool->iState, unit->PID_cool->Err, unit->PID_cool->OutP);