fixes #1196 - use basename as ids in HA to support multiple EMS-ESP's

This commit is contained in:
Proddy
2023-06-24 13:28:48 +02:00
parent 27b9aa6ddd
commit 158617f56b
7 changed files with 23 additions and 21 deletions

View File

@@ -164,7 +164,7 @@ void Shower::set_shower_state(bool state, bool force) {
doc["object_id"] = str;
char stat_t[50];
snprintf(stat_t, sizeof(stat_t), "%s/shower_active", Mqtt::base().c_str()); // use base path
snprintf(stat_t, sizeof(stat_t), "%s/shower_active", Mqtt::basename().c_str());
doc["stat_t"] = stat_t;
if (EMSESP::system_.bool_format() == BOOL_FORMAT_TRUEFALSE) {
@@ -181,7 +181,7 @@ void Shower::set_shower_state(bool state, bool force) {
JsonObject dev = doc.createNestedObject("dev");
JsonArray ids = dev.createNestedArray("ids");
ids.add("ems-esp");
ids.add(Mqtt::basename());
// add "availability" section
Mqtt::add_avty_to_doc(stat_t, doc.as<JsonObject>());