diff --git a/src/ebusd/mqtthandler.cpp b/src/ebusd/mqtthandler.cpp index 303118e9..39539f93 100755 --- a/src/ebusd/mqtthandler.cpp +++ b/src/ebusd/mqtthandler.cpp @@ -71,7 +71,8 @@ static const argDef g_mqtt_argDefs[] = { {"mqttretain", O_RETA, nullptr, 0, "Retain all topics instead of only selected global ones"}, {"mqttqos", O_PQOS, "QOS", 0, "Set the QoS value for all topics (0-2) [0]"}, {"mqttint", O_INTF, "FILE", 0, "Read MQTT integration settings from FILE (no default)"}, - {"mqttvar", O_IVAR, "NAME=VALUE[,...]", 0, "Add variable(s) to the read MQTT integration settings"}, + {"mqttvar", O_IVAR, "NAME[+]=VALUE[,...]", 0, "Add variable(s) to the read MQTT integration settings " + "(append to already existing value with \"NAME+=VALUE\")"}, {"mqttjson", O_JSON, "short", af_optional, "Publish in JSON format instead of strings, optionally in short (value directly below field key)"}, {"mqttverbose", O_VERB, nullptr, 0, "Publish all available attributes"}, diff --git a/src/lib/ebus/stringhelper.cpp b/src/lib/ebus/stringhelper.cpp index a3e18301..6a80a328 100644 --- a/src/lib/ebus/stringhelper.cpp +++ b/src/lib/ebus/stringhelper.cpp @@ -373,16 +373,14 @@ void StringReplacers::parseLine(const string& line) { if (pos == string::npos || pos == 0) { return; } - bool emptyIfMissing = false; - string key; - if (line[pos-1] == '?') { - emptyIfMissing = true; - key = line.substr(0, pos-1); - } else { - key = line.substr(0, pos); - } + bool emptyIfMissing = line[pos-1] == '?'; + bool append = !emptyIfMissing && line[pos-1] == '+'; + string key = line.substr(0, (emptyIfMissing || append) ? pos-1 : pos); FileReader::trim(&key); string value = line.substr(pos+1); + if (append) { + value = get(key).str() + value; + } FileReader::trim(&value); if (value.find('%') == string::npos) { set(key, value); // constant value