diff --git a/src/analogsensor.cpp b/src/analogsensor.cpp index 69cd7e8a6..1b805b460 100644 --- a/src/analogsensor.cpp +++ b/src/analogsensor.cpp @@ -451,7 +451,7 @@ void AnalogSensor::publish_values(const bool force) { } config["val_tpl"] = str; - snprintf(str, sizeof(str), "%s_analog_sensor_%s", Mqtt::basename().c_str(), sensor.name().c_str()); + snprintf(str, sizeof(str), "%s_analogsensor_%d", Mqtt::basename().c_str(), sensor.gpio()); config["object_id"] = str; config["uniq_id"] = str; // same as object_id diff --git a/src/dallassensor.cpp b/src/dallassensor.cpp index ccfc7438c..eb1aeab74 100644 --- a/src/dallassensor.cpp +++ b/src/dallassensor.cpp @@ -518,7 +518,7 @@ void DallasSensor::publish_values(const bool force) { } config["val_tpl"] = str; - snprintf(str, sizeof(str), "%s_temperature_sensor_%s", Mqtt::basename().c_str(), sensor.id().c_str()); + snprintf(str, sizeof(str), "%s_dallassensor_%s", Mqtt::basename().c_str(), sensor.id().c_str()); config["object_id"] = str; config["uniq_id"] = str; // same as object_id diff --git a/src/mqtt.cpp b/src/mqtt.cpp index 43f0c8d3c..404b8878b 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -593,8 +593,10 @@ void Mqtt::on_connect() { void Mqtt::ha_status() { StaticJsonDocument doc; - doc["uniq_id"] = "ems-esp-system"; - doc["object_id"] = "ems_esp_status"; + char uniq[70]; + snprintf(uniq, sizeof(uniq), "%s_status", mqtt_basename_.c_str()); + doc["uniq_id"] = uniq; + doc["object_id"] = uniq; doc["~"] = mqtt_base_; // default ems-esp // doc["avty_t"] = "~/status"; // commented out, as it causes errors in HA sometimes // doc["json_attr_t"] = "~/heartbeat"; // store also as HA attributes @@ -614,7 +616,7 @@ void Mqtt::ha_status() { ids.add("ems-esp"); char topic[MQTT_TOPIC_MAX_SIZE]; - snprintf(topic, sizeof(topic), "binary_sensor/%s/system/config", mqtt_basename_.c_str()); + snprintf(topic, sizeof(topic), "binary_sensor/%s/status/config", mqtt_basename_.c_str()); Mqtt::publish_ha(topic, doc.as()); // publish the config payload with retain flag // create the sensors - must match the MQTT payload keys