From ccc1e7dae4d8cfe3dd8545a133c7574b5c604f81 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 7 Jun 2023 09:31:22 -0500 Subject: [PATCH] get rid of strings --- components/ratgdo/ratgdo.cpp | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/components/ratgdo/ratgdo.cpp b/components/ratgdo/ratgdo.cpp index 47f7bd4..61de3d9 100644 --- a/components/ratgdo/ratgdo.cpp +++ b/components/ratgdo/ratgdo.cpp @@ -480,34 +480,29 @@ namespace ratgdo { void RATGDOComponent::sendDoorStatus() { - DoorState val = static_cast(this->store_.doorState); - ESP_LOGD(TAG, "Door state: %s", door_state_to_string(val)); + ESP_LOGD(TAG, "Door state: %s", door_state_to_string(static_cast(this->store_.doorState))); this->status_door_pin_->digital_write(this->store_.doorState == 1); } void RATGDOComponent::sendLightStatus() { - LightState val = static_cast(this->store_.lightState); - ESP_LOGD(TAG, "Light state %s", light_state_to_string(val)); + ESP_LOGD(TAG, "Light state %s", light_state_to_string(static_cast(this->store_.lightState))); } void RATGDOComponent::sendLockStatus() { - LockState val = static_cast(this->store_.lockState); - ESP_LOGD(TAG, "Lock state %s", lock_state_to_string(val)); + ESP_LOGD(TAG, "Lock state %s", lock_state_to_string(static_cast(this->store_.lockState))); } void RATGDOComponent::sendMotionStatus() { - MotionState val = static_cast(this->store_.motionState); - ESP_LOGD(TAG, "Motion state %s", motion_state_to_string(val)); + ESP_LOGD(TAG, "Motion state %s", motion_state_to_string(static_cast(this->store_.motionState))); this->store_.motionState = MotionState::MOTION_STATE_CLEAR; // reset motion state } void RATGDOComponent::sendObstructionStatus() { - ObstructionState val = static_cast(this->store_.obstructionState); - ESP_LOGD(TAG, "Obstruction state %s", obstruction_state_to_string(val)); + ESP_LOGD(TAG, "Obstruction state %s", obstruction_state_to_string(static_cast(this->store_.obstructionState))); this->status_obst_pin_->digital_write(this->store_.obstructionState == 0); } @@ -558,8 +553,7 @@ namespace ratgdo { void RATGDOComponent::openDoor() { if (this->store_.doorState == DoorState::DOOR_STATE_OPEN || this->store_.doorState == DoorState::DOOR_STATE_OPENING) { - DoorState val = static_cast(this->store_.doorState); - ESP_LOGD(TAG, "The door is already %s", door_state_to_string(val)); + ESP_LOGD(TAG, "The door is already %s", door_state_to_string(static_cast(this->store_.doorState))); return; } toggleDoor(); @@ -568,8 +562,7 @@ namespace ratgdo { void RATGDOComponent::closeDoor() { if (this->store_.doorState == DoorState::DOOR_STATE_CLOSED || this->store_.doorState == DoorState::DOOR_STATE_CLOSING) { - DoorState val = static_cast(this->store_.doorState); - ESP_LOGD(TAG, "The door is already %s", door_state_to_string(val)); + ESP_LOGD(TAG, "The door is already %s", door_state_to_string(static_cast(this->store_.doorState))); return; } toggleDoor();