ESPHome 2026.5.1
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::restart {
7
8static const char *const TAG = "restart";
9
11 // Acknowledge
12 this->publish_state(false);
13
14 if (state) {
15 ESP_LOGI(TAG, "Restarting device");
16 // Let MQTT settle a bit
17 delay(100); // NOLINT
19 }
20}
21void RestartSwitch::dump_config() { LOG_SWITCH("", "Restart Switch", this); }
22
23} // namespace esphome::restart
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: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.