Controller will stay alive if it has to
This commit is contained in:
parent
7991a37d4d
commit
089476facc
@ -231,7 +231,7 @@ void loopHandler() {
|
|||||||
if (waterLevelPercent <= waterMinPercent.get()) {
|
if (waterLevelPercent <= waterMinPercent.get()) {
|
||||||
/* let the ESP sleep qickly, as nothing must be done */
|
/* let the ESP sleep qickly, as nothing must be done */
|
||||||
if ((millis() >= (MIN_TIME_RUNNING * MS_TO_S)) && (deepSleepTime.get() > 0)) {
|
if ((millis() >= (MIN_TIME_RUNNING * MS_TO_S)) && (deepSleepTime.get() > 0)) {
|
||||||
mDeepSleep = true;
|
mDeepSleep = true;
|
||||||
Serial << "No Water for pumps" << endl;
|
Serial << "No Water for pumps" << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -240,7 +240,6 @@ void loopHandler() {
|
|||||||
/* Pump is running, go to sleep after defined time */
|
/* Pump is running, go to sleep after defined time */
|
||||||
if (millis() >= ((MIN_TIME_RUNNING + 5) &&
|
if (millis() >= ((MIN_TIME_RUNNING + 5) &&
|
||||||
(deepSleepTime.get() > 0))) {
|
(deepSleepTime.get() > 0))) {
|
||||||
Serial << "No sleeping activated (maximum)" << endl;
|
|
||||||
mDeepSleep = true;
|
mDeepSleep = true;
|
||||||
} else if ((millis() >= ((MIN_TIME_RUNNING * MS_TO_S) + 0)) &&
|
} else if ((millis() >= ((MIN_TIME_RUNNING * MS_TO_S) + 0)) &&
|
||||||
(deepSleepTime.get() > 0)) {
|
(deepSleepTime.get() > 0)) {
|
||||||
@ -303,7 +302,7 @@ bool aliveHandler(const HomieRange& range, const String& value) {
|
|||||||
} else {
|
} else {
|
||||||
mAlive=false;
|
mAlive=false;
|
||||||
}
|
}
|
||||||
Serial << "Controller " << (mAlive ? " has coffee" : " is tired") << endl;
|
Serial << "HOMIE | Controller " << (mAlive ? " has coffee" : " is tired") << endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -502,7 +501,7 @@ void setup() {
|
|||||||
.setUnit("V");
|
.setUnit("V");
|
||||||
sensorWater.advertise("remaining").setDatatype("number").setUnit("%");
|
sensorWater.advertise("remaining").setDatatype("number").setUnit("%");
|
||||||
|
|
||||||
stayAlive.advertise("stay").setName("Alive").setDatatype("number").settable(aliveHandler);
|
stayAlive.advertise("alive").setName("Alive").setDatatype("number").settable(aliveHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
Homie.setup();
|
Homie.setup();
|
||||||
@ -669,8 +668,17 @@ void loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Serial << (millis()/ 1000) << "s running; sleeeping ..." << endl;
|
if (!mAlive) {
|
||||||
Serial.flush();
|
Serial << (millis()/ 1000) << "s running; sleeeping ..." << endl;
|
||||||
esp_deep_sleep_start();
|
Serial.flush();
|
||||||
|
esp_deep_sleep_start();
|
||||||
|
} else {
|
||||||
|
mDeepSleep = false;
|
||||||
|
|
||||||
|
if (((millis()) % 10000) == 0) {
|
||||||
|
/* tell everybody how long we are awoken */
|
||||||
|
stayAlive.setProperty("alive").send( String(millis()/ 1000) );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user