1238 pub_domoticz_temp(unit->air_idx, temp); |
1238 pub_domoticz_temp(unit->air_idx, temp); |
1239 } |
1239 } |
1240 unit->air_temperature = temp; |
1240 unit->air_temperature = temp; |
1241 unit->air_state = 0; |
1241 unit->air_state = 0; |
1242 } else { |
1242 } else { |
1243 syslog(LOG_NOTICE, "deviation error deviation=%d, old=%d new=%d", deviation, unit->air_temperature, temp); |
1243 syslog(LOG_NOTICE, "deviation error air deviation=%d, old=%d new=%d", deviation, unit->air_temperature, temp); |
1244 } |
1244 } |
1245 } else if (rc == DEVPRESENT_ERROR) { |
1245 } else if (rc == DEVPRESENT_ERROR) { |
1246 unit->air_state = 1; |
1246 unit->air_state = 1; |
1247 } else { |
1247 } else { |
1248 unit->air_state = 2; |
1248 unit->air_state = 2; |
1260 pub_domoticz_temp(unit->beer_idx, temp); |
1260 pub_domoticz_temp(unit->beer_idx, temp); |
1261 } |
1261 } |
1262 unit->beer_temperature = temp; |
1262 unit->beer_temperature = temp; |
1263 unit->beer_state = 0; |
1263 unit->beer_state = 0; |
1264 } else { |
1264 } else { |
1265 syslog(LOG_NOTICE, "deviation error deviation=%d, old=%d new=%d", deviation, unit->beer_temperature, temp); |
1265 syslog(LOG_NOTICE, "deviation error beer deviation=%d, old=%d new=%d", deviation, unit->beer_temperature, temp); |
1266 } |
1266 } |
1267 } else if (rc == DEVPRESENT_ERROR) { |
1267 } else if (rc == DEVPRESENT_ERROR) { |
1268 unit->beer_state = 1; |
1268 unit->beer_state = 1; |
1269 } else { |
1269 } else { |
1270 unit->beer_state = 2; |
1270 unit->beer_state = 2; |
|
1271 } |
|
1272 } |
|
1273 |
|
1274 if (unit->chiller_address) { |
|
1275 rc = device_in(unit->chiller_address, &temp); |
|
1276 if (rc == DEVPRESENT_YES) { |
|
1277 deviation = 40000; |
|
1278 if ((unit->chiller_temperature == 0) || |
|
1279 (unit->chiller_temperature && (temp > (int)unit->chiller_temperature - deviation) && (temp < ((int)unit->chiller_temperature + deviation)))) { |
|
1280 if (unit->chiller_temperature != temp) { |
|
1281 unit->mqtt_flag |= MQTT_FLAG_DATA; |
|
1282 pub_domoticz_temp(unit->chiller_idx, temp); |
|
1283 } |
|
1284 unit->chiller_temperature = temp; |
|
1285 unit->chiller_state = 0; |
|
1286 } else { |
|
1287 syslog(LOG_NOTICE, "deviation error chiller deviation=%d, old=%d new=%d", deviation, unit->chiller_temperature, temp); |
|
1288 } |
|
1289 } else if (rc == DEVPRESENT_ERROR) { |
|
1290 unit->chiller_state = 1; |
|
1291 } else { |
|
1292 unit->chiller_state = 2; |
1271 } |
1293 } |
1272 } |
1294 } |
1273 |
1295 |
1274 /* |
1296 /* |
1275 * Unit door state, default is closed. |
1297 * Unit door state, default is closed. |
1627 * Prevent extreme cooling |
1649 * Prevent extreme cooling |
1628 */ |
1650 */ |
1629 if ((unit->mode == UNITMODE_BEER) && ((unit->air_temperature / 1000.0) < (unit->PID_cool->Input - 5.0))) { |
1651 if ((unit->mode == UNITMODE_BEER) && ((unit->air_temperature / 1000.0) < (unit->PID_cool->Input - 5.0))) { |
1630 unit->PID_cool->OutP = 0.0; |
1652 unit->PID_cool->OutP = 0.0; |
1631 } |
1653 } |
|
1654 /* |
|
1655 * Prevent cooling if we use a chiller and the chiller temperature is not low enough. |
|
1656 */ |
|
1657 if (unit->chiller_address && (unit->chiller_state == 0)) { |
|
1658 if ((unit->chiller_temperature / 1000.0) > (unit->PID_cool->Input - 1)) { |
|
1659 unit->PID_cool->OutP = 0.0; |
|
1660 } |
|
1661 } |
1632 if (debug) |
1662 if (debug) |
1633 fprintf(stdout, "Cool: sp=%.2f Input=%.2f iState=%.2f Err=%.2f Out=%.2f\n", |
1663 fprintf(stdout, "Cool: sp=%.2f Input=%.2f iState=%.2f Err=%.2f Out=%.2f\n", |
1634 unit->PID_cool->SetP, unit->PID_cool->Input, unit->PID_cool->iState, unit->PID_cool->Err, unit->PID_cool->OutP); |
1664 unit->PID_cool->SetP, unit->PID_cool->Input, unit->PID_cool->iState, unit->PID_cool->Err, unit->PID_cool->OutP); |
1635 if (seconds == 60) { |
1665 if (seconds == 60) { |
1636 syslog(LOG_NOTICE, "Cool: sp=%.2f Input=%.2f iState=%.2f Err=%.2f Out=%.2f", |
1666 syslog(LOG_NOTICE, "Cool: sp=%.2f Input=%.2f iState=%.2f Err=%.2f Out=%.2f", |