Compare commits

...

2 Commits

Author SHA1 Message Date
David Zálešák 33e0c1e26a Přidání více metrik pro export 2 years ago
David Zálešák 9f92104be4 Oprava get requestu
převedení požadované hodnoty na String
2 years ago

@ -24,6 +24,7 @@ DallasTemperature sensor(&oneWire);
float temperature; float temperature;
String metrics; String metrics;
bool heating;
float reqTemp = 21.5; float reqTemp = 21.5;
float offset = 0.25; float offset = 0.25;
@ -127,13 +128,13 @@ void setup() {
String repply; String repply;
if(request->hasParam("temp")) { if(request->hasParam("temp")) {
repply = temperature; repply = String(temperature);
}else if(request->hasParam("relay")){ }else if(request->hasParam("relay")){
repply = !digitalRead(RELAY_PIN); repply = String(heating);
}else if(THERMOSTAT && request->hasParam("reqtemp")){ }else if(THERMOSTAT && request->hasParam("reqtemp")){
repply = reqTemp; repply = String(reqTemp);
}else if(THERMOSTAT && request->hasParam("offset")) { }else if(THERMOSTAT && request->hasParam("offset")) {
repply = offset; repply = String(offset);
}else{ }else{
repply = "unknown parameter"; repply = "unknown parameter";
} }
@ -165,9 +166,11 @@ void notFound(AsyncWebServerRequest *request) {
void thermostatCheck(){ void thermostatCheck(){
if(temperature < (reqTemp - offset)){ if(temperature < (reqTemp - offset)){
digitalWrite(RELAY_PIN, false); heating = 1;
digitalWrite(RELAY_PIN, !heating);
}else if(temperature > (reqTemp + offset)){ }else if(temperature > (reqTemp + offset)){
digitalWrite(RELAY_PIN, true); heating = 0;
digitalWrite(RELAY_PIN, !heating);
} }
} }
@ -181,6 +184,15 @@ void readSensor() {
} }
metrics = "temp "; metrics = "temp ";
metrics += temperature; metrics += temperature;
metrics += "\nraw_temp ";
metrics += tempC;
metrics += "\nheating ";
metrics += heating;
metrics += "\nreqTemp ";
metrics += reqTemp;
metrics += "\noffset ";
metrics += offset;
} }
void startConversion() { void startConversion() {