mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-01-26 16:49:11 +03:00
don't need to add name to ids each time for HA
This commit is contained in:
@@ -1451,7 +1451,7 @@ void Mqtt::add_ha_dev_section(JsonObject doc, const char * name, const char * mo
|
|||||||
// create dev section
|
// create dev section
|
||||||
JsonObject dev_json = doc["dev"].to<JsonObject>();
|
JsonObject dev_json = doc["dev"].to<JsonObject>();
|
||||||
|
|
||||||
// add ids and name - with capitalize first letter
|
// add ids and name - capitalize first letter of the name
|
||||||
JsonArray ids = dev_json["ids"].to<JsonArray>(); // ids, it is an array with a single element
|
JsonArray ids = dev_json["ids"].to<JsonArray>(); // ids, it is an array with a single element
|
||||||
if (name != nullptr) {
|
if (name != nullptr) {
|
||||||
// for ids, replace all spaces with -
|
// for ids, replace all spaces with -
|
||||||
@@ -1464,8 +1464,7 @@ void Mqtt::add_ha_dev_section(JsonObject doc, const char * name, const char * mo
|
|||||||
dev_json["name"] = Mqtt::basename() + " " + cap_name;
|
dev_json["name"] = Mqtt::basename() + " " + cap_name;
|
||||||
free(cap_name);
|
free(cap_name);
|
||||||
} else {
|
} else {
|
||||||
ids.add(Mqtt::basename());
|
ids.add(Mqtt::basename()); // no name, assign it to the main EMS-ESP device in HA
|
||||||
dev_json["name"] = Mqtt::basename();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the model, manufacturer and version
|
// create the model, manufacturer and version
|
||||||
|
|||||||
Reference in New Issue
Block a user