ESPHome
2026.5.1
Loading...
Searching...
No Matches
esphome
components
shutdown
button
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
"
4
#include "
esphome/core/application.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::shutdown
{
14
15
static
const
char
*
const
TAG =
"shutdown.button"
;
16
17
void
ShutdownButton::dump_config
() { LOG_BUTTON(
""
,
"Shutdown Button"
,
this
); }
18
void
ShutdownButton::press_action
() {
19
ESP_LOGI(TAG,
"Shutting down"
);
20
// Let MQTT settle a bit
21
delay
(100);
// NOLINT
22
App
.
run_safe_shutdown_hooks
();
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
application.h
esphome::Application::run_safe_shutdown_hooks
void run_safe_shutdown_hooks()
Definition
application.cpp:278
esphome::shutdown::ShutdownButton::dump_config
void dump_config() override
Definition
shutdown_button.cpp:17
esphome::shutdown::ShutdownButton::press_action
void press_action() override
Definition
shutdown_button.cpp:18
hal.h
log.h
esphome::shutdown
Definition
shutdown_button.cpp:13
esphome::delay
void HOT delay(uint32_t ms)
Definition
hal.cpp:85
esphome::App
Application App
Global storage of Application pointer - only one Application can exist.
shutdown_button.h
Generated by
1.12.0