From 205ad56bad41937fe857170120b38e7c7805570d Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 25 Oct 2024 17:23:09 +0200 Subject: [PATCH] test --- components/tc_bus/tc_bus.cpp | 23 +---------------------- components/tc_bus/tc_bus.h | 13 ------------- 2 files changed, 1 insertion(+), 35 deletions(-) diff --git a/components/tc_bus/tc_bus.cpp b/components/tc_bus/tc_bus.cpp index cd221f2..def513b 100644 --- a/components/tc_bus/tc_bus.cpp +++ b/components/tc_bus/tc_bus.cpp @@ -57,10 +57,8 @@ namespace esphome this->pref_.save(&this->model_); } - #ifdef USE_SELECT if (this->intercom_model_select_ != nullptr) this->intercom_model_select_->publish_state(model_to_string(model_)); - #endif #if defined(USE_ESP_IDF) || (defined(USE_ARDUINO) && defined(ESP32)) ESP_LOGD(TAG, "Check for Doorman Hardware"); @@ -101,10 +99,8 @@ namespace esphome } #endif - #ifdef USE_TEXT_SENSOR if (this->hardware_version_text_sensor_ != nullptr) this->hardware_version_text_sensor_->publish_state(this->hardware_version_str_); - #endif this->rx_pin_->setup(); this->tx_pin_->setup(); @@ -116,15 +112,11 @@ namespace esphome this->rx_pin_->attach_interrupt(TCBusComponentStore::gpio_intr, &this->store_, gpio::INTERRUPT_ANY_EDGE); // Reset Sensors - #ifdef USE_TEXT_SENSOR if (this->bus_command_text_sensor_ != nullptr) this->bus_command_text_sensor_->publish_state(""); - #endif - #ifdef USE_BINARY_SENSOR if (this->door_readiness_binary_sensor_ != nullptr) this->door_readiness_binary_sensor_->publish_initial_state(false); - #endif for (auto &listener : listeners_) { @@ -149,16 +141,12 @@ namespace esphome ESP_LOGCONFIG(TAG, " Hardware: %s", this->hardware_version_str_.c_str()); - #ifdef USE_BINARY_SENSOR ESP_LOGCONFIG(TAG, "Binary Sensors:"); LOG_BINARY_SENSOR(" ", "Door readiness", this->door_readiness_binary_sensor_); - #endif - #ifdef USE_TEXT_SENSOR ESP_LOGCONFIG(TAG, "Text Sensors:"); LOG_TEXT_SENSOR(" ", "Last Bus Command", this->bus_command_text_sensor_); LOG_TEXT_SENSOR(" ", "Hardware Version", this->hardware_version_text_sensor_); - #endif } void TCBusComponent::loop() @@ -411,20 +399,15 @@ namespace esphome bool door_readiness_state = cmd_data.payload == 1; ESP_LOGD(TAG, "Door readiness: %s", YESNO(door_readiness_state)); - #ifdef USE_BINARY_SENSOR if (this->door_readiness_binary_sensor_ != nullptr) this->door_readiness_binary_sensor_->publish_state(door_readiness_state); - #endif } else if (cmd_data.type == COMMAND_TYPE_END_OF_DOOR_READINESS) { ESP_LOGD(TAG, "Door readiness: %s", YESNO(false)); - #ifdef USE_BINARY_SENSOR if (this->door_readiness_binary_sensor_ != nullptr) - this->door_readiness_binary_sensor_->publish_state(false); - #endif - } + this->door_readiness_binary_sensor_->publish_state(false); } else if (cmd_data.type == COMMAND_TYPE_PROGRAMMING_MODE) { ESP_LOGD(TAG, "Programming Mode: %s", YESNO(cmd_data.payload == 1)); @@ -455,10 +438,8 @@ namespace esphome } // Publish Command to Last Bus Command Sensor - #ifdef USE_TEXT_SENSOR if (this->bus_command_text_sensor_ != nullptr) this->bus_command_text_sensor_->publish_state(cmd_data.command_hex); - #endif // If the command was received, notify the listeners if (received) @@ -935,7 +916,6 @@ namespace esphome } } - #ifdef USE_SELECT void IntercomModelSelect::control(const std::string &value) { this->publish_state(value); @@ -944,7 +924,6 @@ namespace esphome this->parent_->model_ = model; this->parent_->pref_.save(&model); } - #endif } // namespace tc_bus } // namespace esphome \ No newline at end of file diff --git a/components/tc_bus/tc_bus.h b/components/tc_bus/tc_bus.h index edbbd85..c104fc8 100644 --- a/components/tc_bus/tc_bus.h +++ b/components/tc_bus/tc_bus.h @@ -9,13 +9,8 @@ #include "esphome/core/hal.h" #include "esphome/core/helpers.h" #include "esphome/core/log.h" - -#ifdef USE_TEXT_SENSOR #include "esphome/components/text_sensor/text_sensor.h" -#endif -#ifdef USE_SELECT #include "esphome/components/select/select.h" -#endif namespace esphome { @@ -71,16 +66,10 @@ namespace esphome class TCBusComponent : public Component { - #ifdef USE_SELECT SUB_SELECT(intercom_model) - #endif - #ifdef USE_TEXT_SENSOR SUB_TEXT_SENSOR(bus_command) SUB_TEXT_SENSOR(hardware_version) - #endif - #ifdef USE_BINARY_SENSOR SUB_BINARY_SENSOR(door_readiness) - #endif public: void set_rx_pin(InternalGPIOPin *pin) { this->rx_pin_ = pin; } @@ -145,14 +134,12 @@ namespace esphome ESPPreferenceObject pref_; }; - #ifdef USE_SELECT class IntercomModelSelect : public select::Select, public Parented { public: IntercomModelSelect() = default; protected: void control(const std::string &value) override; }; - #endif } // namespace tc_bus