ESPHome  2025.2.0
logger_level_select.cpp
Go to the documentation of this file.
1 #include "logger_level_select.h"
2 
3 namespace esphome {
4 namespace logger {
5 
7  auto value = this->at(level);
8  if (!value) {
9  return;
10  }
11  Select::publish_state(value.value());
12 }
13 
15  this->parent_->add_listener([this](int level) { this->publish_state(level); });
16  this->publish_state(this->parent_->get_log_level());
17 }
18 
19 void LoggerLevelSelect::control(const std::string &value) {
20  auto level = this->index_of(value);
21  if (!level)
22  return;
23  this->parent_->set_log_level(level.value());
24 }
25 
26 } // namespace logger
27 } // namespace esphome
void control(const std::string &value) override
optional< std::string > at(size_t index) const
Return the (optional) option value at the provided index offset.
Definition: select.cpp:52
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
optional< size_t > index_of(const std::string &option) const
Find the (optional) index offset of the provided option value.
Definition: select.cpp:35