Skip to content

Commit

Permalink
add mqtt base to topic - emsesp#759
Browse files Browse the repository at this point in the history
  • Loading branch information
proddy committed Nov 30, 2022
1 parent 424234e commit 7f18dd9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/analogsensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 1 addition & 3 deletions src/dallassensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 7f18dd9

Please sign in to comment.