use task for restart to allow delay and give a chance to web server to
send reponse back
This commit is contained in:
parent
c82cb3670c
commit
7adc710271
@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/platformio/platformio-core/develop/platformio/assets/schema/library.json",
|
||||
"name": "ha-mqtt",
|
||||
"version": "1.7.0",
|
||||
"version": "1.8.0",
|
||||
"description": "Home Assistant classes for integration with MQTT auto discovery",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@ -30,6 +30,10 @@ namespace HaESP {
|
||||
Sensor::mapSensors["restart_reason"]->updateState(ESP.getResetReason().c_str());
|
||||
}, &ts);
|
||||
|
||||
Task tRestart(1 * TASK_SECOND, TASK_ONCE, []() {
|
||||
ESP.restart();
|
||||
}, &ts);
|
||||
|
||||
Task tWifi(3 * TASK_MINUTE, TASK_FOREVER, []() {
|
||||
Sensor::mapSensors["wifi_signal_strength"]->updateState(to_string(WiFi.RSSI()).c_str());
|
||||
}, &ts);
|
||||
@ -82,7 +86,7 @@ namespace HaESP {
|
||||
Builder<Button>& restartButton() {
|
||||
return Builder<Button>::instance(new Button{"Restart", "restart",
|
||||
[](const char* msg) {
|
||||
if (strcmp("PRESS", msg) == 0) ESP.restart();
|
||||
if (strcmp("PRESS", msg) == 0) tRestart.restartDelayed();
|
||||
}
|
||||
})
|
||||
.withIcon("mdi:restart");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user