fix missing prefix with mqtt integration and without --mqtttopic (fixes #575)

This commit is contained in:
John
2022-03-19 12:58:48 +01:00
parent aa8137ddf3
commit 7356871cea
+3
View File
@@ -1020,6 +1020,9 @@ MqttHandler::MqttHandler(UserInfo* userInfo, BusHandler* busHandler, MessageMap*
m_replacers.set("version", PACKAGE_VERSION);
if (m_replacers["prefix"].empty()) {
string line = m_replacers.get("topic", true);
if (line.empty() || line=="/") {
line = string(PACKAGE); // ensure prefix if cmdline topic is absent
}
m_replacers.set("prefix", line);
m_replacers.set("prefixn", removeTrailingNonTopicPart(line));
}