ESPHome 2025.5.0
Loading...
Searching...
No Matches
restart_switch.cpp
Go to the documentation of this file.
1#include "restart_switch.h"
2#include "esphome/core/hal.h"
3#include "esphome/core/log.h"
5
6namespace esphome {
7namespace restart {
8
9static const char *const TAG = "restart";
10
12 // Acknowledge
13 this->publish_state(false);
14
15 if (state) {
16 ESP_LOGI(TAG, "Restarting device...");
17 // Let MQTT settle a bit
18 delay(100); // NOLINT
20 }
21}
22void RestartSwitch::dump_config() { LOG_SWITCH("", "Restart Switch", this); }
23
24} // namespace restart
25} // namespace esphome
void write_state(bool state) override
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.