mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-08 00:39:50 +03:00
replace HA ~ with hardcoded base name
This commit is contained in:
@@ -151,13 +151,17 @@ void Shower::set_shower_state(bool state, bool force) {
|
||||
ha_configdone_ = true;
|
||||
|
||||
StaticJsonDocument<EMSESP_JSON_SIZE_HA_CONFIG> doc;
|
||||
|
||||
doc["name"] = "Shower Active";
|
||||
|
||||
char str[70];
|
||||
snprintf(str, sizeof(str), "%s_shower_active", Mqtt::basename().c_str());
|
||||
doc["uniq_id"] = str;
|
||||
doc["object_id"] = str;
|
||||
doc["~"] = Mqtt::base();
|
||||
doc["stat_t"] = "~/shower_active";
|
||||
|
||||
char stat_t[50];
|
||||
snprintf(stat_t, sizeof(stat_t), "%s/shower_active", Mqtt::base().c_str()); // use base path
|
||||
doc["stat_t"] = stat_t;
|
||||
|
||||
// always render boolean as strings for HA
|
||||
char result[12];
|
||||
@@ -169,7 +173,7 @@ void Shower::set_shower_state(bool state, bool force) {
|
||||
ids.add("ems-esp");
|
||||
|
||||
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
||||
snprintf(topic, sizeof(topic), "binary_sensor/%s/shower_active/config", Mqtt::base().c_str());
|
||||
snprintf(topic, sizeof(topic), "binary_sensor/%s/shower_active/config", Mqtt::basename().c_str());
|
||||
Mqtt::publish_ha(topic, doc.as<JsonObject>()); // publish the config payload with retain flag
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user