mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-05-21 13:33:27 +02:00
Add shutdown and safe_mode button (#2918)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Co-authored-by: Jos Suanet <jos@suanet.net>
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
#include "safe_mode_button.h"
|
||||
#include "esphome/core/hal.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include "esphome/core/application.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace safe_mode {
|
||||
|
||||
static const char *const TAG = "safe_mode.button";
|
||||
|
||||
void SafeModeButton::set_ota(ota::OTAComponent *ota) { this->ota_ = ota; }
|
||||
|
||||
void SafeModeButton::press_action() {
|
||||
ESP_LOGI(TAG, "Restarting device in safe mode...");
|
||||
this->ota_->set_safe_mode_pending(true);
|
||||
|
||||
// Let MQTT settle a bit
|
||||
delay(100); // NOLINT
|
||||
App.safe_reboot();
|
||||
}
|
||||
|
||||
void SafeModeButton::dump_config() { LOG_BUTTON("", "Safe Mode Button", this); }
|
||||
|
||||
} // namespace safe_mode
|
||||
} // namespace esphome
|
||||
Reference in New Issue
Block a user