Files
esphome/esphome/components/logger/select/logger_level_select.cpp
T
2596b6096f Fix log level selector when selecting levels above INFO (#10368)
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
2025-10-03 14:28:38 -05:00

25 lines
643 B
C++

#include "logger_level_select.h"
namespace esphome::logger {
void LoggerLevelSelect::publish_state(int level) {
const auto &option = this->at(level_to_index(level));
if (!option)
return;
Select::publish_state(option.value());
}
void LoggerLevelSelect::setup() {
this->parent_->add_listener([this](int level) { this->publish_state(level); });
this->publish_state(this->parent_->get_log_level());
}
void LoggerLevelSelect::control(const std::string &value) {
const auto index = this->index_of(value);
if (!index)
return;
this->parent_->set_log_level(index_to_level(index.value()));
}
} // namespace esphome::logger