Skip to content

Commit

Permalink
change ha-mqtt tto topic
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDvP committed Sep 4, 2023
1 parent f1034f4 commit 09a1572
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/mqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1261,27 +1261,27 @@ void Mqtt::add_avty_to_doc(const char * state_t, const JsonObject & doc, const c
StaticJsonDocument<512> avty_json;

snprintf(tpl, sizeof(tpl), "%s/status", mqtt_base_.c_str());
avty_json["t"] = tpl;
avty_json["topic"] = tpl;
snprintf(tpl, sizeof(tpl), tpl_draft, "value == 'online'");
avty_json["val_tpl"] = tpl;
avty.add(avty_json);
avty_json.clear();
avty_json["t"] = state_t;
avty_json["topic"] = 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_json.clear();
avty_json["t"] = state_t;
avty_json["topic"] = state_t;
snprintf(tpl, sizeof(tpl), tpl_draft, cond2);
avty_json["val_tpl"] = tpl;
avty.add(avty_json);
}

if (negcond != nullptr) {
avty_json.clear();
avty_json["t"] = state_t;
avty_json["topic"] = state_t;
snprintf(tpl, sizeof(tpl), "{{'offline' if %s else 'online'}}", negcond);
avty_json["val_tpl"] = tpl;
avty.add(avty_json);
Expand Down

0 comments on commit 09a1572

Please sign in to comment.