diff --git a/esphome/components/runtime_stats/__init__.py b/esphome/components/runtime_stats/__init__.py index aff0bf086f..a36e8bfd28 100644 --- a/esphome/components/runtime_stats/__init__.py +++ b/esphome/components/runtime_stats/__init__.py @@ -17,7 +17,7 @@ CONFIG_SCHEMA = cv.Schema( { cv.GenerateID(): cv.declare_id(RuntimeStatsCollector), cv.Optional( - CONF_LOG_INTERVAL, default=60000 + CONF_LOG_INTERVAL, default="60s" ): cv.positive_time_period_milliseconds, } ) diff --git a/esphome/components/runtime_stats/runtime_stats.h b/esphome/components/runtime_stats/runtime_stats.h index 20b0c08313..e2f8bee563 100644 --- a/esphome/components/runtime_stats/runtime_stats.h +++ b/esphome/components/runtime_stats/runtime_stats.h @@ -23,10 +23,10 @@ class ComponentRuntimeStats { public: ComponentRuntimeStats() : period_count_(0), - total_count_(0), period_time_ms_(0), - total_time_ms_(0), period_max_time_ms_(0), + total_count_(0), + total_time_ms_(0), total_max_time_ms_(0) {} void record_time(uint32_t duration_ms) { diff --git a/esphome/core/application.cpp b/esphome/core/application.cpp index 6face23e3c..085b4941d1 100644 --- a/esphome/core/application.cpp +++ b/esphome/core/application.cpp @@ -4,6 +4,9 @@ #include "esphome/core/hal.h" #include #include +#ifdef USE_RUNTIME_STATS +#include "esphome/components/runtime_stats/runtime_stats.h" +#endif #ifdef USE_STATUS_LED #include "esphome/components/status_led/status_led.h" diff --git a/esphome/core/application.h b/esphome/core/application.h index 2cdcdf9e6a..f2b5cb5c89 100644 --- a/esphome/core/application.h +++ b/esphome/core/application.h @@ -9,9 +9,6 @@ #include "esphome/core/hal.h" #include "esphome/core/helpers.h" #include "esphome/core/preferences.h" -#ifdef USE_RUNTIME_STATS -#include "esphome/components/runtime_stats/runtime_stats.h" -#endif #include "esphome/core/scheduler.h" #ifdef USE_DEVICES diff --git a/esphome/core/component.cpp b/esphome/core/component.cpp index 8dbd054602..3b1120bdd7 100644 --- a/esphome/core/component.cpp +++ b/esphome/core/component.cpp @@ -9,6 +9,9 @@ #include "esphome/core/hal.h" #include "esphome/core/helpers.h" #include "esphome/core/log.h" +#ifdef USE_RUNTIME_STATS +#include "esphome/components/runtime_stats/runtime_stats.h" +#endif namespace esphome { diff --git a/esphome/core/component.h b/esphome/core/component.h index c7342cd563..3734473a02 100644 --- a/esphome/core/component.h +++ b/esphome/core/component.h @@ -6,9 +6,6 @@ #include #include "esphome/core/optional.h" -#ifdef USE_RUNTIME_STATS -#include "esphome/components/runtime_stats/runtime_stats.h" -#endif namespace esphome { diff --git a/tests/components/runtime_stats/common.yaml b/tests/components/runtime_stats/common.yaml new file mode 100644 index 0000000000..b434d1b5a7 --- /dev/null +++ b/tests/components/runtime_stats/common.yaml @@ -0,0 +1,2 @@ +# Test runtime_stats component with default configuration +runtime_stats: diff --git a/tests/components/runtime_stats/test.esp32-ard.yaml b/tests/components/runtime_stats/test.esp32-ard.yaml new file mode 100644 index 0000000000..dade44d145 --- /dev/null +++ b/tests/components/runtime_stats/test.esp32-ard.yaml @@ -0,0 +1 @@ +<<: !include common.yaml