diff --git a/components/tc_bus/tc_bus.cpp b/components/tc_bus/tc_bus.cpp index 4c4a8806..eda0d261 100644 --- a/components/tc_bus/tc_bus.cpp +++ b/components/tc_bus/tc_bus.cpp @@ -57,9 +57,10 @@ namespace esphome this->pref_.save(this->model_); } + #ifdef USE_SELECT if (this->intercom_model_select_ != nullptr) this->intercom_model_select_->publish_state(this->model_); - + #endif #if defined(USE_ESP_IDF) || (defined(USE_ARDUINO) && defined(ESP32)) ESP_LOGD(TAG, "Check for Doorman Hardware"); @@ -100,10 +101,10 @@ 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(); @@ -115,15 +116,15 @@ 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_) { @@ -409,16 +410,20 @@ namespace esphome { bool door_readiness_state = cmd_data.payload == 1; ESP_LOGD(TAG, "Door readiness: %s", YESNO(door_readiness_state)); - if (this->door_readiness_binary_sensor_ != nullptr) { + + #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)); - if (this->door_readiness_binary_sensor_ != nullptr) { + + #ifdef USE_BINARY_SENSOR + if (this->door_readiness_binary_sensor_ != nullptr) this->door_readiness_binary_sensor_->publish_state(false); - } + #endif } else if (cmd_data.type == COMMAND_TYPE_PROGRAMMING_MODE) { @@ -450,10 +455,10 @@ 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)