From 0b0ca1efd197a0fd200945d44a5480d13949ccab Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Tue, 7 Mar 2023 07:15:49 +0100 Subject: [PATCH] fix avty --- src/mqtt.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mqtt.cpp b/src/mqtt.cpp index d3caecf74..e5172cf2d 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -1434,20 +1434,22 @@ void Mqtt::add_avty_to_doc(const char * state_t, const JsonObject & doc, const c snprintf(tpl, sizeof(tpl), tpl_draft, "value == 'online'"); avty_json["val_tpl"] = tpl; avty.add(avty_json); - avty.clear(); + avty_json.clear(); avty_json["t"] = state_t; snprintf(tpl, sizeof(tpl), tpl_draft, cond1 == nullptr ? "value is defined" : cond1); avty_json["val_tpl"] = tpl; avty.add(avty_json); if (cond2 != nullptr) { - avty.clear(); + avty_json.clear(); + avty_json["t"] = state_t; snprintf(tpl, sizeof(tpl), tpl_draft, cond2); avty_json["val_tpl"] = tpl; avty.add(avty_json); } if (negcond != nullptr) { - avty.clear(); + avty_json.clear(); + avty_json["t"] = state_t; snprintf(tpl, sizeof(tpl), "{{'offline' if %s else 'online'}}", negcond); avty_json["val_tpl"] = tpl; avty.add(avty_json);