little edit shelly
This commit is contained in:
parent
029d75cd33
commit
f3ec7476b2
@ -78,7 +78,6 @@ void loop() {
|
|||||||
ESP.restart();
|
ESP.restart();
|
||||||
}
|
}
|
||||||
if (buttonActive) {
|
if (buttonActive) {
|
||||||
delay (500);
|
|
||||||
jsonContent = {};
|
jsonContent = {};
|
||||||
jsonContent["token"] = apiToken;
|
jsonContent["token"] = apiToken;
|
||||||
requestJson = "";
|
requestJson = "";
|
||||||
@ -88,8 +87,9 @@ void loop() {
|
|||||||
EEPROM.commit();
|
EEPROM.commit();
|
||||||
sendDataToWeb();
|
sendDataToWeb();
|
||||||
buttonActive = false;
|
buttonActive = false;
|
||||||
|
} else {
|
||||||
|
loadDataFromWeb();
|
||||||
}
|
}
|
||||||
loadDataFromWeb();
|
|
||||||
} else {
|
} else {
|
||||||
server.handleClient();
|
server.handleClient();
|
||||||
}
|
}
|
||||||
@ -117,6 +117,7 @@ bool wifiVerify(int t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void loadDataFromWeb() {
|
void loadDataFromWeb() {
|
||||||
|
delay(500);
|
||||||
jsonContent = {};
|
jsonContent = {};
|
||||||
jsonContent["token"] = apiToken;
|
jsonContent["token"] = apiToken;
|
||||||
requestJson = "";
|
requestJson = "";
|
||||||
@ -148,16 +149,12 @@ void loadDataFromWeb() {
|
|||||||
WiFi.hostname(hostName);
|
WiFi.hostname(hostName);
|
||||||
Serial.println("state: " + (String)state + ", realState: " + (String)realState);
|
Serial.println("state: " + (String)state + ", realState: " + (String)realState);
|
||||||
if (state != realState && !buttonActive) {
|
if (state != realState && !buttonActive) {
|
||||||
if (state == 1 && realState == 0) {
|
realState = state;
|
||||||
Serial.println("ON state: " + (String)state + ", realState: " + (String)realState);
|
|
||||||
realState = 1;
|
|
||||||
} else {
|
|
||||||
Serial.println("OFF");
|
|
||||||
realState = 0;
|
|
||||||
}
|
|
||||||
digitalWrite(RELAY, realState);
|
digitalWrite(RELAY, realState);
|
||||||
EEPROM.write(0, realState);
|
EEPROM.write(0, realState);
|
||||||
EEPROM.commit();
|
EEPROM.commit();
|
||||||
|
} else {
|
||||||
|
state = realState;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user