fix for HA topic names. HA doesn't like - in the name

This commit is contained in:
proddy
2021-03-06 16:53:33 +01:00
parent ac524bf7e8
commit 5b7a2eb33d

View File

@@ -383,7 +383,8 @@ void DallasSensor::publish_values(const bool force) {
ids.add("ems-esp"); ids.add("ems-esp");
char topic[100]; char topic[100];
snprintf_P(topic, sizeof(topic), PSTR("homeassistant/sensor/%s/dallas_%s/config"), Mqtt::base().c_str(), sensor.to_string().c_str()); // use sensor number as HA doesn't like '-' in the topic name
snprintf_P(topic, sizeof(topic), PSTR("homeassistant/sensor/%s/dallas_sensor%d/config"), Mqtt::base().c_str(), sensor_no);
Mqtt::publish_ha(topic, config.as<JsonObject>()); Mqtt::publish_ha(topic, config.as<JsonObject>());
registered_ha_[sensor_no - 1] = true; registered_ha_[sensor_no - 1] = true;