From 7f18dd942fc7fc776bc0cd735102878a0690ac61 Mon Sep 17 00:00:00 2001 From: Proddy Date: Wed, 30 Nov 2022 21:17:41 +0100 Subject: [PATCH] add mqtt base to topic - #759 --- src/analogsensor.cpp | 3 +-- src/dallassensor.cpp | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/analogsensor.cpp b/src/analogsensor.cpp index 38f01fbe8..69cd7e8a6 100644 --- a/src/analogsensor.cpp +++ b/src/analogsensor.cpp @@ -451,8 +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), "analog_sensor_%d", sensor.gpio()); + snprintf(str, sizeof(str), "%s_analog_sensor_%s", Mqtt::basename().c_str(), sensor.name().c_str()); config["object_id"] = str; config["uniq_id"] = str; // same as object_id diff --git a/src/dallassensor.cpp b/src/dallassensor.cpp index 9d933b7d0..ccfc7438c 100644 --- a/src/dallassensor.cpp +++ b/src/dallassensor.cpp @@ -518,15 +518,13 @@ 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), "temperature_sensor_%s", sensor.id().c_str()); + snprintf(str, sizeof(str), "%s_temperature_sensor_%s", Mqtt::basename().c_str(), sensor.id().c_str()); config["object_id"] = str; config["uniq_id"] = str; // same as object_id snprintf(str, sizeof(str), "%s", sensor.name().c_str()); config["name"] = str; - config["uniq_id"] = str; JsonObject dev = config.createNestedObject("dev"); JsonArray ids = dev.createNestedArray("ids"); ids.add("ems-esp");