Skip to content

Commit

Permalink
Refactor set_programming_mode
Browse files Browse the repository at this point in the history
  • Loading branch information
AzonInc committed Sep 18, 2024
1 parent f7a1ef7 commit 21c7366
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions components/tc_bus/tc_bus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ namespace esphome
}
} else if (cmd_data.type == COMMAND_TYPE_PROGRAMMING_MODE) {
ESP_LOGD(TAG, "Programming Mode: %s", YESNO(cmd_data.address == 1));
this->programming_mode_ = cmd_data.address == 1;
}

// Publish Command to Last Bus Command Sensor
Expand Down Expand Up @@ -511,15 +512,7 @@ namespace esphome
void TCBusComponent::set_programming_mode(bool enabled)
{
this->programming_mode_ = enabled;

if(enabled)
{
send_command_generate(COMMAND_TYPE_PROGRAMMING_MODE, 1, 0);
}
else
{
send_command_generate(COMMAND_TYPE_PROGRAMMING_MODE, 0, 0);
}
send_command_generate(COMMAND_TYPE_PROGRAMMING_MODE, enabled ? 1 : 0, 0);
}

} // namespace tc_bus
Expand Down

0 comments on commit 21c7366

Please sign in to comment.