diff --git a/esp32/include/LogDefines.h b/esp32/include/LogDefines.h index dc6ff3c..4d3b894 100644 --- a/esp32/include/LogDefines.h +++ b/esp32/include/LogDefines.h @@ -29,6 +29,9 @@ #define LOG_PUMP_AND_DOWNLOADMODE "Download mode, ignoring pump request" #define LOG_PUMP_AND_DOWNLOADMODE_CODE 2 +#define LOG_VERY_COLD_WATER "Water potentially frozen, ignoring pump request" +#define LOG_VERY_COLD_WATER -7 + //msg is dynamic defined #define LOG_PUMP_INEFFECTIVE -4 #define LOG_PUMP_STARTED_CODE 10 diff --git a/esp32/src/main.cpp b/esp32/src/main.cpp index 369cbc5..c9d6ead 100644 --- a/esp32/src/main.cpp +++ b/esp32/src/main.cpp @@ -90,6 +90,8 @@ long lastSendPumpUpdate = 0; long pumpTargetMl = -1; #endif +float waterTemp = 30; + /*************************** Hardware abstraction *****************************/ OneWire oneWire(SENSOR_ONEWIRE); @@ -267,6 +269,7 @@ void readOneWireSensors() { mqttWrite(&sensorTemp, TEMPERATUR_SENSOR_WATER, String(temp)); Serial << "Water Temperatur " << temp << " °C " << endl; + waterTemp = temp; } /* Always send the sensor address with the temperatur value */ mqttWrite(&sensorTemp, String(buf), String(temp)); @@ -1085,25 +1088,31 @@ void plantcontrol() } #endif // TIMED_LIGHT_PIN - + bool isLiquid = waterTemp > 5; bool hasWater = true; // FIXME remaining > waterLevelMin.get(); // FIXME no water warning message pumpToRun = determineNextPump(isLowLight); // early aborts if (pumpToRun != -1) { - if (hasWater) - { - if (mDownloadMode) + if(isLiquid){ + if (hasWater) { - log(LOG_LEVEL_INFO, LOG_PUMP_AND_DOWNLOADMODE, LOG_PUMP_AND_DOWNLOADMODE_CODE); + if (mDownloadMode) + { + log(LOG_LEVEL_INFO, LOG_PUMP_AND_DOWNLOADMODE, LOG_PUMP_AND_DOWNLOADMODE_CODE); + pumpToRun = -1; + } + } + else + { + log(LOG_LEVEL_ERROR, LOG_PUMP_BUTNOTANK_MESSAGE, LOG_PUMP_BUTNOTANK_CODE); pumpToRun = -1; } } - else - { + else{ log(LOG_LEVEL_ERROR, LOG_PUMP_BUTNOTANK_MESSAGE, LOG_PUMP_BUTNOTANK_CODE); - pumpToRun = -1; + pumpToRun = -1; } }