This commit is contained in:
J. Nick Koston 2023-06-05 12:14:49 -05:00
parent 4af7a079d8
commit e027d1cf45
No known key found for this signature in database
1 changed files with 1 additions and 55 deletions

View File

@ -81,21 +81,11 @@ void doorStateLoop() {
if (doorState != "reed_closed") { if (doorState != "reed_closed") {
ESP_LOGD(TAG, "Reed switch closed"); ESP_LOGD(TAG, "Reed switch closed");
doorState = "reed_closed"; doorState = "reed_closed";
if (isConfigFileOk) {
bootstrapManager.publish(overallStatusTopic.c_str(), "reed_closed",
true);
bootstrapManager.publish(doorStatusTopic.c_str(), "reed_closed",
true);
}
digitalWrite(STATUS_DOOR, HIGH); digitalWrite(STATUS_DOOR, HIGH);
} }
} else if (doorState != "reed_open") { } else if (doorState != "reed_open") {
ESP_LOGD(TAG, "Reed switch open"); ESP_LOGD(TAG, "Reed switch open");
doorState = "reed_open"; doorState = "reed_open";
if (isConfigFileOk) {
bootstrapManager.publish(overallStatusTopic.c_str(), "reed_open", true);
bootstrapManager.publish(doorStatusTopic.c_str(), "reed_open", true);
}
digitalWrite(STATUS_DOOR, LOW); digitalWrite(STATUS_DOOR, LOW);
} }
} }
@ -114,10 +104,6 @@ void doorStateLoop() {
if (doorPositionCounter - lastDirectionChangeCounter > 5) { if (doorPositionCounter - lastDirectionChangeCounter > 5) {
if (doorState != "opening") { if (doorState != "opening") {
ESP_LOGD(TAG, "Door Opening..."); ESP_LOGD(TAG, "Door Opening...");
if (isConfigFileOk) {
bootstrapManager.publish(overallStatusTopic.c_str(), "opening", true);
bootstrapManager.publish(doorStatusTopic.c_str(), "opening", true);
}
} }
lastDirectionChangeCounter = doorPositionCounter; lastDirectionChangeCounter = doorPositionCounter;
doorState = "opening"; doorState = "opening";
@ -126,10 +112,6 @@ void doorStateLoop() {
if (lastDirectionChangeCounter - doorPositionCounter > 5) { if (lastDirectionChangeCounter - doorPositionCounter > 5) {
if (doorState != "closing") { if (doorState != "closing") {
ESP_LOGD(TAG, "Door Closing..."); ESP_LOGD(TAG, "Door Closing...");
if (isConfigFileOk) {
bootstrapManager.publish(overallStatusTopic.c_str(), "closing", true);
bootstrapManager.publish(doorStatusTopic.c_str(), "closing", true);
}
} }
lastDirectionChangeCounter = doorPositionCounter; lastDirectionChangeCounter = doorPositionCounter;
doorState = "closing"; doorState = "closing";
@ -141,12 +123,6 @@ void doorStateLoop() {
if (doorState == "closing") { if (doorState == "closing") {
doorState = "closed"; doorState = "closed";
ESP_LOGD(TAG, "Closed"); ESP_LOGD(TAG, "Closed");
if (isConfigFileOk) {
bootstrapManager.publish(overallStatusTopic.c_str(), doorState.c_str(),
true);
bootstrapManager.publish(doorStatusTopic.c_str(), doorState.c_str(),
true);
}
digitalWrite(STATUS_DOOR, LOW); digitalWrite(STATUS_DOOR, LOW);
} }
@ -154,12 +130,6 @@ void doorStateLoop() {
if (doorState == "opening") { if (doorState == "opening") {
doorState = "open"; doorState = "open";
ESP_LOGD(TAG, "Open"); ESP_LOGD(TAG, "Open");
if (isConfigFileOk) {
bootstrapManager.publish(overallStatusTopic.c_str(), doorState.c_str(),
true);
bootstrapManager.publish(doorStatusTopic.c_str(), doorState.c_str(),
true);
}
digitalWrite(STATUS_DOOR, HIGH); digitalWrite(STATUS_DOOR, HIGH);
} }
} }
@ -337,14 +307,7 @@ void obstructionDetected() {
if (interruptTime - lastInterruptTime > 250) { if (interruptTime - lastInterruptTime > 250) {
doorIsObstructed = true; doorIsObstructed = true;
digitalWrite(STATUS_OBST, HIGH); digitalWrite(STATUS_OBST, HIGH);
ESP_LOGD(TAG, "Obstruction Detected"); ESP_LOGD(TAG, "Obstruction Detected");
if (isConfigFileOk) {
bootstrapManager.publish(overallStatusTopic.c_str(), "obstructed", true);
bootstrapManager.publish(obstructionStatusTopic.c_str(), "obstructed",
true);
}
} }
lastInterruptTime = interruptTime; lastInterruptTime = interruptTime;
} }
@ -353,32 +316,15 @@ void obstructionCleared() {
if (doorIsObstructed) { if (doorIsObstructed) {
doorIsObstructed = false; doorIsObstructed = false;
digitalWrite(STATUS_OBST, LOW); digitalWrite(STATUS_OBST, LOW);
ESP_LOGD(TAG, "Obstruction Cleared"); ESP_LOGD(TAG, "Obstruction Cleared");
if (isConfigFileOk) {
bootstrapManager.publish(overallStatusTopic.c_str(), "clear", true);
bootstrapManager.publish(obstructionStatusTopic.c_str(), "clear", true);
}
} }
} }
void sendDoorStatus() { void sendDoorStatus() { ESP_LOGD(TAG, "Door state %s", doorState); }
ESP_LOGD(TAG, "Door state %s", doorState);
if (isConfigFileOk) {
bootstrapManager.publish(overallStatusTopic.c_str(), doorState.c_str(),
true);
bootstrapManager.publish(doorStatusTopic.c_str(), doorState.c_str(), true);
}
}
void sendCurrentCounter() { void sendCurrentCounter() {
String msg = String(rollingCodeCounter); String msg = String(rollingCodeCounter);
ESP_LOGD(TAG, "Current counter %d", rollingCodeCounter); ESP_LOGD(TAG, "Current counter %d", rollingCodeCounter);
if (isConfigFileOk) {
bootstrapManager.publish(rollingCodeTopic.c_str(), msg.c_str(), true);
}
} }
/********************************** MANAGE HARDWARE BUTTON /********************************** MANAGE HARDWARE BUTTON