garage_esp32.ino move endpoint /sprinkler/program to /irrigation
This commit is contained in:
@@ -372,7 +372,8 @@ void setup() {
|
||||
request->send(200, "application/json", "{ \"action\": \"start\" }");
|
||||
}
|
||||
else {
|
||||
pinStatus(request);
|
||||
stopSprinklers();
|
||||
request->send(200, "application/json", "{ \"action\": \"stop\" }");
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -381,12 +382,17 @@ void setup() {
|
||||
}
|
||||
});
|
||||
|
||||
server.on("/sprinkler/program", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
||||
server.on("/irrigation", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
||||
String action;
|
||||
if (request->hasParam("action")) {
|
||||
|
||||
Serial.println("action");
|
||||
action = request->getParam("action")->value();
|
||||
|
||||
if (action.equals("start") and (request->hasParam("duration"))) {
|
||||
Serial.println(action.equals("start"));
|
||||
Serial.println(request->hasParam("duration"));
|
||||
|
||||
if (action.equals("start") and request->hasParam("duration")) {
|
||||
String duration = request->getParam("duration")->value();
|
||||
sprinklerDuration = duration.toInt();
|
||||
sprinklerDuration = sprinklerDuration * 60 * 1000;
|
||||
@@ -396,12 +402,12 @@ void setup() {
|
||||
digitalWrite(PIN_SPRINKLER4, LOW);
|
||||
request->send(200, "application/json", "{ \"action\": \"start\" }");
|
||||
}
|
||||
}
|
||||
else {
|
||||
stopSprinklers();
|
||||
programStatus = false;
|
||||
programStatus = 0;
|
||||
request->send(200, "application/json", "{ \"action\": \"stop\" }");
|
||||
}
|
||||
}
|
||||
|
||||
String statusString = "false";
|
||||
if (programStatus > 0) {
|
||||
|
||||
Reference in New Issue
Block a user