otoceni logiky rele

master
David Zálešák 4 years ago
parent 2180f3ae01
commit e55076de1b

@ -107,7 +107,7 @@ void setup() {
} }
}else{ }else{
if (request->hasParam("relay")) { if (request->hasParam("relay")) {
boolean state = request->getParam("relay")->value() == "1"; boolean state = request->getParam("relay")->value() == "0";
digitalWrite(RELAY_PIN, state); digitalWrite(RELAY_PIN, state);
repply = "success"; repply = "success";
}else{ }else{
@ -124,7 +124,7 @@ void setup() {
if(request->hasParam("temp")) { if(request->hasParam("temp")) {
repply = temperature; repply = temperature;
}else if(request->hasParam("relay")){ }else if(request->hasParam("relay")){
repply = digitalRead(RELAY_PIN); repply = !digitalRead(RELAY_PIN);
}else if(THERMOSTAT && request->hasParam("reqtemp")){ }else if(THERMOSTAT && request->hasParam("reqtemp")){
repply = reqTemp; repply = reqTemp;
}else if(THERMOSTAT && request->hasParam("offset")) { }else if(THERMOSTAT && request->hasParam("offset")) {
@ -158,9 +158,9 @@ void notFound(AsyncWebServerRequest *request) {
void thermostatCheck(){ void thermostatCheck(){
if(temperature < (reqTemp - offset)){ if(temperature < (reqTemp - offset)){
digitalWrite(RELAY_PIN, true);
}else if(temperature > (reqTemp + offset)){
digitalWrite(RELAY_PIN, false); digitalWrite(RELAY_PIN, false);
}else if(temperature > (reqTemp + offset)){
digitalWrite(RELAY_PIN, true);
} }
} }