From eb6f40c060850561806f172d4911b6ee69e47897 Mon Sep 17 00:00:00 2001 From: Marius Muja Date: Sun, 25 Jun 2023 08:52:16 -0700 Subject: [PATCH] Use door stop command in place of toggle (#16) Co-authored-by: J. Nick Koston --- base.yaml | 2 +- components/ratgdo/ratgdo.cpp | 20 ++++++++++---------- components/ratgdo/ratgdo.h | 18 +++++++++++++----- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/base.yaml b/base.yaml index 3997d50..93ec369 100644 --- a/base.yaml +++ b/base.yaml @@ -180,7 +180,7 @@ button: id($id_prefix).query_openings(); - platform: template - id: ${id_prefix}_test + id: ${id_prefix}_sync name: "Sync" entity_category: diagnostic on_press: diff --git a/components/ratgdo/ratgdo.cpp b/components/ratgdo/ratgdo.cpp index ad5e992..e2da7ee 100644 --- a/components/ratgdo/ratgdo.cpp +++ b/components/ratgdo/ratgdo.cpp @@ -483,12 +483,12 @@ namespace ratgdo { void RATGDOComponent::openDoor() { - doorCommand(data::OPEN); + doorCommand(data::DOOR_OPEN); } void RATGDOComponent::closeDoor() { - doorCommand(data::CLOSE); + doorCommand(data::DOOR_CLOSE); } void RATGDOComponent::stopDoor() @@ -497,12 +497,12 @@ namespace ratgdo { ESP_LOGV(TAG, "The door is not moving."); return; } - toggleDoor(); + doorCommand(data::DOOR_STOP); } void RATGDOComponent::toggleDoor() { - doorCommand(data::TOGGLE); + doorCommand(data::DOOR_TOGGLE); } void RATGDOComponent::doorCommand(uint32_t data) @@ -519,37 +519,37 @@ namespace ratgdo { void RATGDOComponent::lightOn() { this->lightState = LightState::LIGHT_STATE_ON; - transmit(command::LIGHT, data::ON); + transmit(command::LIGHT, data::LIGHT_ON); } void RATGDOComponent::lightOff() { this->lightState = LightState::LIGHT_STATE_OFF; - transmit(command::LIGHT, data::OFF); + transmit(command::LIGHT, data::LIGHT_OFF); } void RATGDOComponent::toggleLight() { this->lightState = light_state_toggle(this->lightState); - transmit(command::LIGHT, data::TOGGLE); + transmit(command::LIGHT, data::LIGHT_TOGGLE); } // Lock functions void RATGDOComponent::lock() { this->lockState = LockState::LOCK_STATE_LOCKED; - transmit(command::LOCK, data::ON); + transmit(command::LOCK, data::LOCK_ON); } void RATGDOComponent::unlock() { - transmit(command::LOCK, data::OFF); + transmit(command::LOCK, data::LOCK_OFF); } void RATGDOComponent::toggleLock() { this->lockState = lock_state_toggle(this->lockState); - transmit(command::LOCK, data::TOGGLE); + transmit(command::LOCK, data::LOCK_TOGGLE); } void RATGDOComponent::saveCounter() diff --git a/components/ratgdo/ratgdo.h b/components/ratgdo/ratgdo.h index 6503480..87f9906 100644 --- a/components/ratgdo/ratgdo.h +++ b/components/ratgdo/ratgdo.h @@ -62,11 +62,19 @@ namespace ratgdo { */ namespace data { - const uint32_t OFF = 0; - const uint32_t CLOSE = 0; - const uint32_t ON = 1; - const uint32_t OPEN = 1; - const uint32_t TOGGLE = 2; + const uint32_t LIGHT_OFF = 0; + const uint32_t LIGHT_ON = 1; + const uint32_t LIGHT_TOGGLE = 2; + const uint32_t LIGHT_TOGGLE2 = 3; + + const uint32_t LOCK_OFF = 0; + const uint32_t LOCK_ON = 1; + const uint32_t LOCK_TOGGLE = 2; + + const uint32_t DOOR_CLOSE = 0; + const uint32_t DOOR_OPEN = 1; + const uint32_t DOOR_TOGGLE = 2; + const uint32_t DOOR_STOP = 3; } namespace command {