From 6b67acbeb5fc6fae713ed81f7ee549f53a3d42ff Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Fri, 14 Apr 2023 14:29:28 +1200 Subject: [PATCH] debug component, allow without debug logging (#4685) --- esphome/components/debug/__init__.py | 16 ---------------- esphome/components/debug/debug_component.cpp | 4 ++++ 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/esphome/components/debug/__init__.py b/esphome/components/debug/__init__.py index 223c3c8df1..c18baa1cca 100644 --- a/esphome/components/debug/__init__.py +++ b/esphome/components/debug/__init__.py @@ -1,15 +1,11 @@ import esphome.codegen as cg import esphome.config_validation as cv -import esphome.final_validate as fv -from esphome.components import logger from esphome.const import ( CONF_BLOCK, CONF_DEVICE, CONF_FRAGMENTATION, CONF_FREE, CONF_ID, - CONF_LEVEL, - CONF_LOGGER, CONF_LOOP_TIME, ) @@ -43,18 +39,6 @@ CONFIG_SCHEMA = cv.Schema( ).extend(cv.polling_component_schema("60s")) -def _final_validate(_): - logger_conf = fv.full_config.get()[CONF_LOGGER] - severity = logger.LOG_LEVEL_SEVERITY.index(logger_conf[CONF_LEVEL]) - if severity < logger.LOG_LEVEL_SEVERITY.index("DEBUG"): - raise cv.Invalid( - "The debug component requires the logger to be at least at DEBUG level" - ) - - -FINAL_VALIDATE_SCHEMA = _final_validate - - async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) await cg.register_component(var, config) diff --git a/esphome/components/debug/debug_component.cpp b/esphome/components/debug/debug_component.cpp index c1ede684e6..9843fa1c99 100644 --- a/esphome/components/debug/debug_component.cpp +++ b/esphome/components/debug/debug_component.cpp @@ -37,6 +37,10 @@ static uint32_t get_free_heap() { } void DebugComponent::dump_config() { +#ifndef ESPHOME_LOG_HAS_DEBUG + return; // Can't log below if debug logging is disabled +#endif + std::string device_info; std::string reset_reason; device_info.reserve(256);