ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
debug_component.h
Go to the documentation of this file.
1#pragma once
2
7#include <span>
8
9#ifdef USE_SENSOR
11#endif
12#ifdef USE_TEXT_SENSOR
14#endif
15
16namespace esphome::debug {
17
18static constexpr size_t DEVICE_INFO_BUFFER_SIZE = 256;
19static constexpr size_t RESET_REASON_BUFFER_SIZE = 128;
20static constexpr size_t WAKEUP_CAUSE_BUFFER_SIZE = 128;
21
22// buf_append_printf is now provided by esphome/core/helpers.h
23
24class DebugComponent final : public PollingComponent {
25 public:
26 void loop() override;
27 void update() override;
28 float get_setup_priority() const override;
29 void dump_config() override;
30
31#ifdef USE_TEXT_SENSOR
32 SUB_TEXT_SENSOR(device_info)
33 SUB_TEXT_SENSOR(reset_reason)
34#endif // USE_TEXT_SENSOR
35#ifdef USE_SENSOR
36 SUB_SENSOR(free)
37 SUB_SENSOR(block)
38#if defined(USE_ESP8266) || defined(USE_ESP32)
39 SUB_SENSOR(fragmentation)
40#endif
41#if defined(USE_ESP32) || defined(USE_LIBRETINY)
42 SUB_SENSOR(min_free)
43#endif
44 SUB_SENSOR(loop_time)
45#ifdef USE_ESP32
46 SUB_SENSOR(psram)
47#endif // USE_ESP32
48 SUB_SENSOR(cpu_frequency)
49#endif // USE_SENSOR
50#ifdef USE_ESP32
51 void on_shutdown() override;
52#endif // USE_ESP32
53 protected:
55
56#ifdef USE_SENSOR
59#endif // USE_SENSOR
60
61#if defined(USE_ESP32) || defined(USE_ZEPHYR)
73#endif
74
75 const char *get_reset_reason_(std::span<char, RESET_REASON_BUFFER_SIZE> buffer);
76 const char *get_wakeup_cause_(std::span<char, WAKEUP_CAUSE_BUFFER_SIZE> buffer);
78 size_t get_device_info_(std::span<char, DEVICE_INFO_BUFFER_SIZE> buffer, size_t pos);
79 void update_platform_();
80};
81
82} // namespace esphome::debug
virtual void on_shutdown()
Definition component.h:179
This class simplifies creating components that periodically check a state.
Definition component.h:532
SUB_TEXT_SENSOR(device_info) SUB_TEXT_SENSOR(reset_reason) SUB_SENSOR(free) SUB_SENSOR(block) SUB_SENSOR(fragmentation) SUB_SENSOR(min_free) SUB_SENSOR(loop_time) SUB_SENSOR(psram) SUB_SENSOR(cpu_frequency) void on_shutdown() override
const char * get_wakeup_cause_(std::span< char, WAKEUP_CAUSE_BUFFER_SIZE > buffer)
float get_setup_priority() const override
void log_partition_info_()
Logs information about the device's partition table.
size_t get_device_info_(std::span< char, DEVICE_INFO_BUFFER_SIZE > buffer, size_t pos)
const char * get_reset_reason_(std::span< char, RESET_REASON_BUFFER_SIZE > buffer)
uint32_t buffer
Definition gif.cpp:50
size_t size_t pos
Definition helpers.h:1333
static void uint32_t