mirror of
https://github.com/esphome/esphome.git
synced 2025-10-07 04:13:47 +01:00
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>
21 lines
787 B
C++
21 lines
787 B
C++
#pragma once
|
|
|
|
#include "esphome/components/select/select.h"
|
|
#include "esphome/core/component.h"
|
|
#include "esphome/components/logger/logger.h"
|
|
|
|
namespace esphome::logger {
|
|
class LoggerLevelSelect : public Component, public select::Select, public Parented<Logger> {
|
|
public:
|
|
void publish_state(int level);
|
|
void setup() override;
|
|
void control(const std::string &value) override;
|
|
|
|
protected:
|
|
// Convert log level to option index (skip CONFIG at level 4)
|
|
static uint8_t level_to_index(uint8_t level) { return (level > ESPHOME_LOG_LEVEL_CONFIG) ? level - 1 : level; }
|
|
// Convert option index to log level (skip CONFIG at level 4)
|
|
static uint8_t index_to_level(uint8_t index) { return (index >= ESPHOME_LOG_LEVEL_CONFIG) ? index + 1 : index; }
|
|
};
|
|
} // namespace esphome::logger
|