From 72f6265b87354beb6020fa205aefec2be7859bfc Mon Sep 17 00:00:00 2001 From: John Date: Sun, 6 Feb 2022 00:41:33 +0100 Subject: [PATCH] add %fieldname --- contrib/etc/ebusd/mqtt-hassio.cfg | 6 ++++-- contrib/etc/ebusd/mqtt-integration.cfg | 6 ++++-- src/ebusd/mqtthandler.cpp | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/contrib/etc/ebusd/mqtt-hassio.cfg b/contrib/etc/ebusd/mqtt-hassio.cfg index f9aa0702..02d89c75 100644 --- a/contrib/etc/ebusd/mqtt-hassio.cfg +++ b/contrib/etc/ebusd/mqtt-hassio.cfg @@ -48,8 +48,10 @@ # Available as "%type_map". # 6. other field specific variables for each field (only once for each message if the topic is field specific): -# %index the field index (excluding ignored fields). -# %field the field name (or the field index if no name is defined or the names are not unique in the message). +# %index the numeric field index (excluding ignored fields). +# %field the field name and key for JSON objects (equals the field index if no name is defined or the names are not +# unique in the message). +# %fieldname the field name (and nothing else like in %field, might be empty though!) # %type the field type (one of "number", "list", "string", "date", "time", or "datetime"). # %basetype the base data type ID (e.g. "UCH"). # %comment the field comment (if any). diff --git a/contrib/etc/ebusd/mqtt-integration.cfg b/contrib/etc/ebusd/mqtt-integration.cfg index bc58eeef..44f11dac 100644 --- a/contrib/etc/ebusd/mqtt-integration.cfg +++ b/contrib/etc/ebusd/mqtt-integration.cfg @@ -42,8 +42,10 @@ # Available as "%type_map". # 6. other field specific variables for each field (only once for each message if the topic is field specific): -# %index the field index (excluding ignored fields). -# %field the field name (or the field index if no name is defined or the names are not unique in the message). +# %index the numeric field index (excluding ignored fields). +# %field the field name and key for JSON objects (equals the field index if no name is defined or the names are not +# unique in the message). +# %fieldname the field name (and nothing else like in %field, might be empty though!) # %type the field type (one of "number", "list", "string", "date", "time", or "datetime"). # %basetype the base data type ID (e.g. "UCH"). # %comment the field comment (if any). diff --git a/src/ebusd/mqtthandler.cpp b/src/ebusd/mqtthandler.cpp index 6d58fadd..2755927d 100755 --- a/src/ebusd/mqtthandler.cpp +++ b/src/ebusd/mqtthandler.cpp @@ -1439,6 +1439,7 @@ void MqttHandler::run() { MqttReplacers values = msgValues; // need a copy here as the contents are manipulated values.set("index", static_cast(index)); values.set("field", fieldName); + values.set("fieldname", field->getName(-1)); values.set("type", typeStr); values.set("type_map", str); values.set("basetype", dataType->getId());