ESPHome 2025.5.0
Loading...
Searching...
No Matches
safe_mode_switch.cpp
Go to the documentation of this file.
1#include "safe_mode_switch.h"
3#include "esphome/core/hal.h"
4#include "esphome/core/log.h"
5
6namespace esphome {
7namespace safe_mode {
8
9static const char *const TAG = "safe_mode.switch";
10
12 this->safe_mode_component_ = safe_mode_component;
13}
14
16 // Acknowledge
17 this->publish_state(false);
18
19 if (state) {
20 ESP_LOGI(TAG, "Restarting device in safe mode...");
22
23 // Let MQTT settle a bit
24 delay(100); // NOLINT
26 }
27}
28
29void SafeModeSwitch::dump_config() { LOG_SWITCH("", "Safe Mode Switch", this); }
30
31} // namespace safe_mode
32} // namespace esphome
SafeModeComponent provides a safe way to recover from repeated boot failures.
Definition safe_mode.h:12
void set_safe_mode_pending(const bool &pending)
Set to true if the next startup will enter safe mode.
Definition safe_mode.cpp:47
void write_state(bool state) override
void set_safe_mode(SafeModeComponent *safe_mode_component)
void publish_state(bool state)
Publish a state to the front-end from the back-end.
Definition switch.cpp:47
bool state
Definition fan.h:0
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
void IRAM_ATTR HOT delay(uint32_t ms)
Definition core.cpp:28
Application App
Global storage of Application pointer - only one Application can exist.