This commit is contained in:
MichaelDvP
2025-12-09 21:11:36 +01:00
parent 515b75160c
commit ac982cbb15
2 changed files with 7 additions and 8 deletions

View File

@@ -195,7 +195,6 @@ void Shower::create_ha_discovery() {
JsonDocument doc;
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
char str[70];
char stat_t[50];
doc["~"] = Mqtt::base();
@@ -213,7 +212,7 @@ void Shower::create_ha_discovery() {
Mqtt::add_ha_bool(doc.as<JsonObject>());
Mqtt::add_ha_dev_section(doc.as<JsonObject>(), "Shower Sensor", nullptr, nullptr, nullptr, false);
Mqtt::add_ha_avail_section(doc.as<JsonObject>(), stat_t, true); // no conditions
Mqtt::add_ha_avail_section(doc.as<JsonObject>(), "~/shower_active", true); // no conditions
snprintf(topic, sizeof(topic), "binary_sensor/%s/shower_active/config", Mqtt::basename().c_str());
ha_configdone_ = Mqtt::queue_ha(topic, doc.as<JsonObject>()); // publish the config payload with retain flag
@@ -225,7 +224,7 @@ void Shower::create_ha_discovery() {
doc["uniq_id"] = str;
doc["def_ent_id"] = (std::string) "sensor." + str;
doc["stat_t"] = "~/shower_data",
doc["stat_t"] = "~/shower_data";
doc["name"] = "Shower Duration";
// don't bother with value template conditions if using Domoticz which doesn't fully support MQTT Discovery
@@ -241,7 +240,7 @@ void Shower::create_ha_discovery() {
// doc["ent_cat"] = "diagnostic";
Mqtt::add_ha_dev_section(doc.as<JsonObject>(), "Shower Sensor", nullptr, nullptr, nullptr, false);
Mqtt::add_ha_avail_section(doc.as<JsonObject>(), stat_t, false, "value_json.duration is defined");
Mqtt::add_ha_avail_section(doc.as<JsonObject>(), "~/shower_data", false, "value_json.duration is defined");
snprintf(topic, sizeof(topic), "sensor/%s/shower_duration/config", Mqtt::basename().c_str());
Mqtt::queue_ha(topic, doc.as<JsonObject>()); // publish the config payload with retain flag