mirror of
https://github.com/esphome/esphome.git
synced 2026-06-01 01:19:45 +08:00
[openthread] static log level code quality improvement (#14456)
Co-authored-by: J. Nick Koston <nick@home-assistant.io>
This commit is contained in:
@@ -14,9 +14,12 @@ import esphome.config_validation as cv
|
|||||||
from esphome.const import (
|
from esphome.const import (
|
||||||
CONF_CHANNEL,
|
CONF_CHANNEL,
|
||||||
CONF_ENABLE_IPV6,
|
CONF_ENABLE_IPV6,
|
||||||
|
CONF_FRAMEWORK,
|
||||||
CONF_ID,
|
CONF_ID,
|
||||||
|
CONF_LOG_LEVEL,
|
||||||
CONF_OUTPUT_POWER,
|
CONF_OUTPUT_POWER,
|
||||||
CONF_USE_ADDRESS,
|
CONF_USE_ADDRESS,
|
||||||
|
PLATFORM_ESP32,
|
||||||
)
|
)
|
||||||
from esphome.core import CORE, TimePeriodMilliseconds
|
from esphome.core import CORE, TimePeriodMilliseconds
|
||||||
import esphome.final_validate as fv
|
import esphome.final_validate as fv
|
||||||
@@ -46,6 +49,15 @@ AUTO_LOAD = ["network"]
|
|||||||
CONFLICTS_WITH = ["wifi"]
|
CONFLICTS_WITH = ["wifi"]
|
||||||
DEPENDENCIES = ["esp32"]
|
DEPENDENCIES = ["esp32"]
|
||||||
|
|
||||||
|
IDF_TO_OT_LOG_LEVEL = {
|
||||||
|
"NONE": "NONE",
|
||||||
|
"ERROR": "CRIT",
|
||||||
|
"WARN": "WARN",
|
||||||
|
"INFO": "NOTE",
|
||||||
|
"DEBUG": "INFO",
|
||||||
|
"VERBOSE": "DEBG",
|
||||||
|
}
|
||||||
|
|
||||||
CONF_DEVICE_TYPES = [
|
CONF_DEVICE_TYPES = [
|
||||||
"FTD",
|
"FTD",
|
||||||
"MTD",
|
"MTD",
|
||||||
@@ -198,6 +210,15 @@ def _final_validate(_):
|
|||||||
"Please set `enable_ipv6: true` in the `network` configuration."
|
"Please set `enable_ipv6: true` in the `network` configuration."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (
|
||||||
|
(esp32_config := full_config.get(PLATFORM_ESP32)) is not None
|
||||||
|
and (fw_config := esp32_config.get(CONF_FRAMEWORK)) is not None
|
||||||
|
and (log_level := fw_config.get(CONF_LOG_LEVEL)) is not None
|
||||||
|
):
|
||||||
|
add_idf_sdkconfig_option("CONFIG_OPENTHREAD_LOG_LEVEL_DYNAMIC", False)
|
||||||
|
ot_log_level = IDF_TO_OT_LOG_LEVEL.get(log_level, log_level)
|
||||||
|
add_idf_sdkconfig_option(f"CONFIG_OPENTHREAD_LOG_LEVEL_{ot_log_level}", True)
|
||||||
|
|
||||||
|
|
||||||
FINAL_VALIDATE_SCHEMA = _final_validate
|
FINAL_VALIDATE_SCHEMA = _final_validate
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
|
esp32:
|
||||||
|
board: esp32-c6-devkitc-1
|
||||||
|
framework:
|
||||||
|
type: esp-idf
|
||||||
|
log_level: DEBUG
|
||||||
|
|
||||||
network:
|
network:
|
||||||
enable_ipv6: true
|
enable_ipv6: true
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user