ESPHome 2025.10.2
Loading...
Searching...
No Matches
logger_level_select.cpp
Go to the documentation of this file.
2
3namespace esphome::logger {
4
6 const auto &option = this->at(level_to_index(level));
7 if (!option)
8 return;
9 Select::publish_state(option.value());
10}
11
13 this->parent_->add_listener([this](int level) { this->publish_state(level); });
14 this->publish_state(this->parent_->get_log_level());
15}
16
17void LoggerLevelSelect::control(const std::string &value) {
18 const auto index = this->index_of(value);
19 if (!index)
20 return;
21 this->parent_->set_log_level(index_to_level(index.value()));
22}
23
24} // namespace esphome::logger
static uint8_t level_to_index(uint8_t level)
void control(const std::string &value) override
static uint8_t index_to_level(uint8_t index)
optional< size_t > index_of(const std::string &option) const
Find the (optional) index offset of the provided option value.
Definition select.cpp:35
optional< std::string > at(size_t index) const
Return the (optional) option value at the provided index offset.
Definition select.cpp:53