From 7adc7102712381336ab1ac9b0df50042b6d4f0e7 Mon Sep 17 00:00:00 2001 From: Nicu Hodos Date: Sat, 6 Sep 2025 21:43:53 +0200 Subject: [PATCH] use task for restart to allow delay and give a chance to web server to send reponse back --- library.json | 2 +- src/esp.h | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/library.json b/library.json index 9885b79..f451edd 100644 --- a/library.json +++ b/library.json @@ -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", diff --git a/src/esp.h b/src/esp.h index 2987e4f..828ee92 100644 --- a/src/esp.h +++ b/src/esp.h @@ -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