Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
AzonInc committed Oct 25, 2024
1 parent fc76eb3 commit 2e1482f
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions components/tc_bus/tc_bus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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();
Expand All @@ -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_)
{
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 2e1482f

Please sign in to comment.