Skip to content

Commit 7f18dd9

Browse files
committed
add mqtt base to topic - emsesp#759
1 parent 424234e commit 7f18dd9

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

src/analogsensor.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,7 @@ void AnalogSensor::publish_values(const bool force) {
451451
}
452452
config["val_tpl"] = str;
453453

454-
// snprintf(str, sizeof(str), "%s_analog_sensor_%s", Mqtt::basename().c_str(), sensor.name().c_str());
455-
snprintf(str, sizeof(str), "analog_sensor_%d", sensor.gpio());
454+
snprintf(str, sizeof(str), "%s_analog_sensor_%s", Mqtt::basename().c_str(), sensor.name().c_str());
456455
config["object_id"] = str;
457456
config["uniq_id"] = str; // same as object_id
458457

src/dallassensor.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -518,15 +518,13 @@ void DallasSensor::publish_values(const bool force) {
518518
}
519519
config["val_tpl"] = str;
520520

521-
// snprintf(str, sizeof(str), "%s_temperature_sensor_%s", Mqtt::basename().c_str(), sensor.id().c_str());
522-
snprintf(str, sizeof(str), "temperature_sensor_%s", sensor.id().c_str());
521+
snprintf(str, sizeof(str), "%s_temperature_sensor_%s", Mqtt::basename().c_str(), sensor.id().c_str());
523522
config["object_id"] = str;
524523
config["uniq_id"] = str; // same as object_id
525524

526525
snprintf(str, sizeof(str), "%s", sensor.name().c_str());
527526
config["name"] = str;
528527

529-
config["uniq_id"] = str;
530528
JsonObject dev = config.createNestedObject("dev");
531529
JsonArray ids = dev.createNestedArray("ids");
532530
ids.add("ems-esp");

0 commit comments

Comments
 (0)