From bafe23431e44f00680bd2617e4c7b8398b2e9004 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Mon, 6 Mar 2023 18:36:27 +0100 Subject: [PATCH] fix avty --- src/mqtt.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/mqtt.cpp b/src/mqtt.cpp index c84c99fc1..8ded6e39c 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -1445,22 +1445,23 @@ 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);