ESPHome  2024.10.2
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 
13 namespace esphome {
14 namespace shutdown {
15 
16 static const char *const TAG = "shutdown.button";
17 
18 void ShutdownButton::dump_config() { LOG_BUTTON("", "Shutdown Button", this); }
20  ESP_LOGI(TAG, "Shutting down...");
21  // Let MQTT settle a bit
22  delay(100); // NOLINT
24 #ifdef USE_ESP8266
25  ESP.deepSleep(0); // NOLINT(readability-static-accessed-through-instance)
26 #endif
27 #ifdef USE_ESP32
28  esp_deep_sleep_start();
29 #endif
30 }
31 
32 } // namespace shutdown
33 } // namespace esphome
Application App
Global storage of Application pointer - only one Application can exist.
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
void IRAM_ATTR HOT delay(uint32_t ms)
Definition: core.cpp:26