From b10c89505ca81a93851b7b0bc660795f9c656904 Mon Sep 17 00:00:00 2001 From: "Adrian A. Baumann" Date: Sat, 27 Jun 2026 01:44:32 +0200 Subject: [PATCH] Retain HA command messages so values survive restarts --- src/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.cpp b/src/main.cpp index 69eebce..b909983 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -258,6 +258,7 @@ static void mqttPublishDiscovery() { doc["name"] = name; doc["state_topic"] = stat; doc["command_topic"] = stat + "/set"; + doc["retain"] = true; // HA publishes commands retained so values survive restarts doc["availability_topic"] = String(mqttCfg.prefix) + "/status"; doc["payload_available"] = MQTT_PAYLOAD_AVAILABLE; doc["payload_not_available"] = MQTT_PAYLOAD_NOT_AVAILABLE;