mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-05-27 08:18:28 +02:00
Uncouple safe_mode from OTA (#6759)
This commit is contained in:
@@ -6,9 +6,11 @@
|
||||
namespace esphome {
|
||||
namespace safe_mode {
|
||||
|
||||
static const char *const TAG = "safe_mode_switch";
|
||||
static const char *const TAG = "safe_mode.switch";
|
||||
|
||||
void SafeModeSwitch::set_ota(esphome::ESPHomeOTAComponent *ota) { this->ota_ = ota; }
|
||||
void SafeModeSwitch::set_safe_mode(SafeModeComponent *safe_mode_component) {
|
||||
this->safe_mode_component_ = safe_mode_component;
|
||||
}
|
||||
|
||||
void SafeModeSwitch::write_state(bool state) {
|
||||
// Acknowledge
|
||||
@@ -16,13 +18,14 @@ void SafeModeSwitch::write_state(bool state) {
|
||||
|
||||
if (state) {
|
||||
ESP_LOGI(TAG, "Restarting device in safe mode...");
|
||||
this->ota_->set_safe_mode_pending(true);
|
||||
this->safe_mode_component_->set_safe_mode_pending(true);
|
||||
|
||||
// Let MQTT settle a bit
|
||||
delay(100); // NOLINT
|
||||
App.safe_reboot();
|
||||
}
|
||||
}
|
||||
|
||||
void SafeModeSwitch::dump_config() { LOG_SWITCH("", "Safe Mode Switch", this); }
|
||||
|
||||
} // namespace safe_mode
|
||||
|
||||
Reference in New Issue
Block a user