Changed QOS for switches

This commit is contained in:
2020-10-22 16:08:38 +03:00
parent 22ae1d5643
commit 8888a0a854
6 changed files with 131 additions and 33 deletions

View File

@@ -148,7 +148,7 @@ void loop() {
if (cRun + 9999 < millis()){
cRun = millis();
char v[11];
itoa(cRun, v, 10);
ultoa(cRun, v, 10);
mqttClient.publish("/home/kor/millislamp", 0, false, v);
}
}
@@ -158,7 +158,7 @@ bool switchLight(uint8_t nLamp, int state, bool pub)
digitalWrite(nLamp, state);
EEPROM.put(0, state);
EEPROM.commit();
if (pub) mqttClient.publish("/home/kor/lamp1", 0, false, state ? "1" : "0");
if (pub) mqttClient.publish("/home/kor/lamp1", 1, false, state ? "1" : "0");
return state;
}
@@ -186,8 +186,8 @@ void onWifiDisconnect(const WiFiEventStationModeDisconnected& event) {
}
void onMqttConnect(bool sessionPresent) {
mqttClient.subscribe("/home/kor/lamp1", 1);
mqttClient.publish("/home/kor/lamp1", 0, false, digitalRead(R_LED) == 1 ? "1" : "0");
mqttClient.subscribe("/home/kor/lamp1", 0);
digitalWrite(B_LED, LOW);
}