From a140383e32e4c8d4b932e2f196465970d0df7fa9 Mon Sep 17 00:00:00 2001 From: c3ma Date: Wed, 28 Oct 2020 21:20:46 +0100 Subject: [PATCH] Disable pumps while OTA running, mode2 is called only once --- esp32/include/PlantCtrl.h | 4 +++- esp32/src/PlantCtrl.cpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/esp32/include/PlantCtrl.h b/esp32/include/PlantCtrl.h index 5b4cf52..57275f8 100644 --- a/esp32/include/PlantCtrl.h +++ b/esp32/include/PlantCtrl.h @@ -60,7 +60,9 @@ public: * @return false */ bool isPumpRequired() { - return (this->mSetting->pSensorDry != NULL) && (this->moistureRaw.getMedian() < this->mSetting->pSensorDry->get()); + return (this->mSetting->pSensorDry != NULL) + && (this->moistureRaw.getMedian() > this->mSetting->pSensorDry->get()) + && (this->mSetting->pSensorDry->get() != DEACTIVATED_PLANT); } HomieInternals::SendingPromise& setProperty(const String& property) const { diff --git a/esp32/src/PlantCtrl.cpp b/esp32/src/PlantCtrl.cpp index e07459d..ec19476 100644 --- a/esp32/src/PlantCtrl.cpp +++ b/esp32/src/PlantCtrl.cpp @@ -21,7 +21,7 @@ Plant::Plant(int pinSensor, int pinPump,int plantId, HomieNode* plant, PlantSett void Plant::init(void) { /* Initialize Home Settings validator */ - this->mSetting->pSensorDry->setDefaultValue(4095); + this->mSetting->pSensorDry->setDefaultValue(DEACTIVATED_PLANT); this->mSetting->pSensorDry->setValidator([] (long candidate) { return (((candidate >= 0) && (candidate <= 4095) ) || candidate == DEACTIVATED_PLANT); });