Change QOS and Time polling sensors
This commit is contained in:
@@ -60,13 +60,13 @@ void onMqttConnect(bool sessionPresent) {
|
||||
// Serial.print("Session present: ");
|
||||
// Serial.println(sessionPresent);
|
||||
//uint16_t packetIdSub =
|
||||
mqttClient.subscribe("/home/kor/lamp1_set", 1);
|
||||
mqttClient.subscribe("/home/kor/lamp1_set", 0);
|
||||
// Serial.print("Subscribing Lamp1, packetId: ");
|
||||
// Serial.println(packetIdSub);
|
||||
//packetIdSub = mqttClient.subscribe("/home/kor/lamp2_set", 1);
|
||||
//Serial.print("Subscribing Lamp2, packetId: ");
|
||||
//Serial.println(packetIdSub);
|
||||
mqttClient.publish("/home/kor/lamp1", 1, false, lStat1 ? "1" : "0");
|
||||
mqttClient.publish("/home/kor/lamp1", 0, false, lStat1 ? "1" : "0");
|
||||
//Serial.println("Publishing at Lamp 1");
|
||||
//mqttClient.publish("/home/kor/lamp2", 1, false, lStat2 ? "1" : "0");
|
||||
//Serial.println("Publishing at Lamp 2");
|
||||
@@ -98,7 +98,7 @@ void onMqttUnsubscribe(uint16_t packetId) {
|
||||
|
||||
void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total) {
|
||||
if(strcmp(topic, "/home/kor/lamp1_set") == 0){
|
||||
if ((char)payload[0] == '1') lStat1 = true;
|
||||
if (atoi(payload) == 1) lStat1 = true;
|
||||
else lStat1 = false;
|
||||
}
|
||||
}
|
||||
@@ -122,12 +122,12 @@ void oneClick()
|
||||
void longPress()
|
||||
{
|
||||
lStat1 = false;
|
||||
mqttClient.publish("/home/bigroom/lamp1_set", 1, false, "0");
|
||||
mqttClient.publish("/home/bigroom/lamp2_set", 1, false, "0");
|
||||
mqttClient.publish("/home/midroom/lamp1_set", 1, false, "0");
|
||||
mqttClient.publish("/home/midroom/lamp2_set", 1, false, "0");
|
||||
mqttClient.publish("/home/smallroom/lamp1_set", 1, false, "0");
|
||||
mqttClient.publish("/home/smallroom/lamp2_set", 1, false, "0");
|
||||
mqttClient.publish("/home/bigroom/lamp1_set", 0, false, "0");
|
||||
mqttClient.publish("/home/bigroom/lamp2_set", 0, false, "0");
|
||||
mqttClient.publish("/home/midroom/lamp1_set", 0, false, "0");
|
||||
mqttClient.publish("/home/midroom/lamp2_set", 0, false, "0");
|
||||
mqttClient.publish("/home/smallroom/lamp1_set", 0, false, "0");
|
||||
mqttClient.publish("/home/smallroom/lamp2_set", 0, false, "0");
|
||||
}
|
||||
|
||||
void setup() {
|
||||
@@ -200,7 +200,7 @@ void loop() {
|
||||
if(lStat1 != oldLStat1){
|
||||
digitalWrite(R_LED, lStat1);
|
||||
oldLStat1 = lStat1;
|
||||
mqttClient.publish("/home/kor/lamp1", 1, false, lStat1 ? "1" : "0");
|
||||
mqttClient.publish("/home/kor/lamp1", 0, false, lStat1 ? "1" : "0");
|
||||
EEPROM.put(0, lStat1);
|
||||
EEPROM.commit();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user