mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
change ha-mqtt tto topic
This commit is contained in:
@@ -1261,19 +1261,19 @@ void Mqtt::add_avty_to_doc(const char * state_t, const JsonObject & doc, const c
|
|||||||
StaticJsonDocument<512> avty_json;
|
StaticJsonDocument<512> avty_json;
|
||||||
|
|
||||||
snprintf(tpl, sizeof(tpl), "%s/status", mqtt_base_.c_str());
|
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'");
|
snprintf(tpl, sizeof(tpl), tpl_draft, "value == 'online'");
|
||||||
avty_json["val_tpl"] = tpl;
|
avty_json["val_tpl"] = tpl;
|
||||||
avty.add(avty_json);
|
avty.add(avty_json);
|
||||||
avty_json.clear();
|
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);
|
snprintf(tpl, sizeof(tpl), tpl_draft, cond1 == nullptr ? "value is defined" : cond1);
|
||||||
avty_json["val_tpl"] = tpl;
|
avty_json["val_tpl"] = tpl;
|
||||||
avty.add(avty_json);
|
avty.add(avty_json);
|
||||||
|
|
||||||
if (cond2 != nullptr) {
|
if (cond2 != nullptr) {
|
||||||
avty_json.clear();
|
avty_json.clear();
|
||||||
avty_json["t"] = state_t;
|
avty_json["topic"] = state_t;
|
||||||
snprintf(tpl, sizeof(tpl), tpl_draft, cond2);
|
snprintf(tpl, sizeof(tpl), tpl_draft, cond2);
|
||||||
avty_json["val_tpl"] = tpl;
|
avty_json["val_tpl"] = tpl;
|
||||||
avty.add(avty_json);
|
avty.add(avty_json);
|
||||||
@@ -1281,7 +1281,7 @@ void Mqtt::add_avty_to_doc(const char * state_t, const JsonObject & doc, const c
|
|||||||
|
|
||||||
if (negcond != nullptr) {
|
if (negcond != nullptr) {
|
||||||
avty_json.clear();
|
avty_json.clear();
|
||||||
avty_json["t"] = state_t;
|
avty_json["topic"] = state_t;
|
||||||
snprintf(tpl, sizeof(tpl), "{{'offline' if %s else 'online'}}", negcond);
|
snprintf(tpl, sizeof(tpl), "{{'offline' if %s else 'online'}}", negcond);
|
||||||
avty_json["val_tpl"] = tpl;
|
avty_json["val_tpl"] = tpl;
|
||||||
avty.add(avty_json);
|
avty.add(avty_json);
|
||||||
|
|||||||
Reference in New Issue
Block a user