ESPHome 2026.5.1
Loading...
Searching...
No Matches
shutdown_button.cpp
Go to the documentation of this file.
1#include "shutdown_button.h"
2#include "esphome/core/hal.h"
3#include "esphome/core/log.h"
5
6#ifdef USE_ESP32
7#include <esp_sleep.h>
8#endif
9#ifdef USE_ESP8266
10#include <Esp.h>
11#endif
12
14
15static const char *const TAG = "shutdown.button";
16
17void ShutdownButton::dump_config() { LOG_BUTTON("", "Shutdown Button", this); }
19 ESP_LOGI(TAG, "Shutting down");
20 // Let MQTT settle a bit
21 delay(100); // NOLINT
23#ifdef USE_ESP8266
24 ESP.deepSleep(0); // NOLINT(readability-static-accessed-through-instance)
25#endif
26#ifdef USE_ESP32
27 esp_deep_sleep_start();
28#endif
29}
30
31} // namespace esphome::shutdown
void HOT delay(uint32_t ms)
Definition hal.cpp:85
Application App
Global storage of Application pointer - only one Application can exist.