This commit is contained in:
J. Nick Koston 2023-06-09 15:29:17 -05:00
parent 45c3fc508a
commit 358249291c
No known key found for this signature in database
1 changed files with 18 additions and 18 deletions

View File

@ -423,11 +423,11 @@ namespace ratgdo {
void RATGDOComponent::stopDoor() void RATGDOComponent::stopDoor()
{ {
if (this->doorState == DoorState::DOOR_STATE_OPENING || this->doorState == DoorState::DOOR_STATE_CLOSING) { if (this->doorState != DoorState::DOOR_STATE_OPENING && this->doorState != DoorState::DOOR_STATE_CLOSING) {
toggleDoor();
} else {
ESP_LOGD(TAG, "The door is not moving."); ESP_LOGD(TAG, "The door is not moving.");
return;
} }
toggleDoor();
} }
void RATGDOComponent::toggleDoor() void RATGDOComponent::toggleDoor()
@ -446,24 +446,24 @@ namespace ratgdo {
{ {
if (this->lightState == LightState::LIGHT_STATE_ON) { if (this->lightState == LightState::LIGHT_STATE_ON) {
ESP_LOGD(TAG, "The light is already on"); ESP_LOGD(TAG, "The light is already on");
} else { return;
toggleLight(); }
// We don't always get the state back so be optimistic toggleLight();
this->previousLightState = this->lightState; // We don't always get the state back so be optimistic
this->lightState = LightState::LIGHT_STATE_ON; this->previousLightState = this->lightState;
} this->lightState = LightState::LIGHT_STATE_ON;
} }
void RATGDOComponent::lightOff() void RATGDOComponent::lightOff()
{ {
if (this->lightState == LightState::LIGHT_STATE_OFF) { if (this->lightState == LightState::LIGHT_STATE_OFF) {
ESP_LOGD(TAG, "The light is already off"); ESP_LOGD(TAG, "The light is already off");
} else { return;
toggleLight();
// We don't always get the state back so be optimistic
this->previousLightState = this->lightState;
this->lightState = LightState::LIGHT_STATE_OFF;
} }
toggleLight();
// We don't always get the state back so be optimistic
this->previousLightState = this->lightState;
this->lightState = LightState::LIGHT_STATE_OFF;
} }
void RATGDOComponent::toggleLight() void RATGDOComponent::toggleLight()
@ -476,18 +476,18 @@ namespace ratgdo {
{ {
if (this->lockState == LockState::LOCK_STATE_LOCKED) { if (this->lockState == LockState::LOCK_STATE_LOCKED) {
ESP_LOGD(TAG, "already locked"); ESP_LOGD(TAG, "already locked");
} else { return;
toggleLock();
} }
toggleLock();
} }
void RATGDOComponent::unlock() void RATGDOComponent::unlock()
{ {
if (this->lockState == LockState::LOCK_STATE_UNLOCKED) { if (this->lockState == LockState::LOCK_STATE_UNLOCKED) {
ESP_LOGD(TAG, "already unlocked"); ESP_LOGD(TAG, "already unlocked");
} else { return;
toggleLock();
} }
toggleLock();
} }
void RATGDOComponent::toggleLock() void RATGDOComponent::toggleLock()