ESPHome 2026.6.0-dev
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::safe_mode {
7
8static const char *const TAG = "safe_mode.switch";
9
11 this->safe_mode_component_ = safe_mode_component;
12}
13
15 // Acknowledge
16 this->publish_state(false);
17
18 if (state) {
19 ESP_LOGI(TAG, "Restarting in safe mode");
21
22 // Let MQTT settle a bit
23 delay(100); // NOLINT
25 }
26}
27
28void SafeModeSwitch::dump_config() { LOG_SWITCH("", "Safe Mode Switch", this); }
29
30} // namespace esphome::safe_mode
SafeModeComponent provides a safe way to recover from repeated boot failures.
Definition safe_mode.h:18
void set_safe_mode_pending(const bool &pending)
Set to true if the next startup will enter safe mode.
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:56
bool state
Definition fan.h:2
void HOT delay(uint32_t ms)
Definition hal.cpp:85
Application App
Global storage of Application pointer - only one Application can exist.