|
|
|
@ -75,13 +75,25 @@ void setup() {
|
|
|
|
|
//========== Web server setup ==========
|
|
|
|
|
|
|
|
|
|
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
|
|
|
|
|
request->send(200, "text/plain", "ESP termostat, tady se bude posílat aplikace z flash paměti");
|
|
|
|
|
request->send(200, "text/plain; charset=utf-8", "ESP termostat, tady se bude posílat aplikace z flash paměti");
|
|
|
|
|
});
|
|
|
|
|
if(METRICS_EXPORT){
|
|
|
|
|
server.on("/metrics", HTTP_GET, [](AsyncWebServerRequest *request){
|
|
|
|
|
request->send(200, "text/plain; charset=utf-8", metrics);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if(METRICS_EXPORT && !THERMOSTAT){
|
|
|
|
|
server.on("/relay", HTTP_GET, [](AsyncWebServerRequest *request){
|
|
|
|
|
boolean state;
|
|
|
|
|
if (request->hasParam("set")) {
|
|
|
|
|
state = request->getParam("set")->value() == "1";
|
|
|
|
|
digitalWrite(RELAY_PIN, state);
|
|
|
|
|
request->send(200, "text/plain; charset=utf-8", "success");
|
|
|
|
|
}else{
|
|
|
|
|
request->send(200, "text/plain; charset=utf-8", String(digitalRead(RELAY_PIN)));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
server.onNotFound(notFound);
|
|
|
|
|
server.begin();
|
|
|
|
|
|
|
|
|
|