Moved from postfix to prefix on HA sensor name tag

This commit is contained in:
Gunnar Skjold 2023-04-01 07:38:24 +02:00
parent 71e0f13f0e
commit 81fedaaa6a
2 changed files with 5 additions and 5 deletions

View File

@ -17,11 +17,11 @@ public:
if(strlen(config.discoveryNameTag) > 0) {
snprintf_P(buf, 128, PSTR("AMS reader (%s)"), config.discoveryNameTag);
deviceName = String(buf);
snprintf_P(buf, 128, PSTR(" (%s)"), config.discoveryNameTag);
sensorNamePostFix = String(buf);
snprintf_P(buf, 128, PSTR("[%s] "), config.discoveryNameTag);
sensorNamePrefix = String(buf);
} else {
deviceName = "AMS reader";
sensorNamePostFix = "";
sensorNamePrefix = "";
}
deviceModel = boardTypeToString(boardType);
manufacturer = boardManufacturerToString(boardType);
@ -82,7 +82,7 @@ private:
String deviceUrl;
String discoveryTopic;
String sensorNamePostFix;
String sensorNamePrefix;
bool l1Init, l2Init, l2eInit, l3Init, l3eInit, l4Init, l4eInit, rtInit, rteInit, pInit, sInit;
bool tInit[32] = {false};

View File

@ -310,8 +310,8 @@ void HomeAssistantMqttHandler::publishSensor(const HomeAssistantSensor& sensor)
uid.replace("]", "");
uid.replace("'", "");
snprintf_P(json, BufferSize, HADISCOVER_JSON,
sensorNamePrefix.c_str(),
sensor.name,
sensorNamePostFix.c_str(),
topic.c_str(), sensor.topic,
deviceUid.c_str(), uid.c_str(),
deviceUid.c_str(), uid.c_str(),