initial proposal

This commit is contained in:
suks.ae
2026-07-31 10:01:42 +02:00
parent 44f4559f3c
commit 45476312ab
+28 -18
View File
@@ -632,24 +632,7 @@ boolean Plugin_037(uint8_t function, struct EventStruct *event, String& string)
}
UserVar.setFloat(event->TaskIndex, x, doublePayload); // Save the new value
if (!checkJson && P037_SEND_EVENTS && Settings.UseRules) { // Generate event of all non-json topic/payloads
String RuleEvent = strformat(F("%s#%s=%s"),
getTaskDeviceName(event->TaskIndex).c_str(),
event->String1.c_str(),
wrapWithQuotesIfContainsParameterSeparatorChar(unparsedPayload).c_str());
P037_addEventToQueue(event, RuleEvent);
}
// Log the event
# if !defined(P037_LIMIT_BUILD_SIZE) || defined(P037_OVERRIDE)
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
addLog(LOG_LEVEL_INFO, strformat(F("IMPT : [%s#%s] : %s"),
getTaskDeviceName(event->TaskIndex).c_str(),
checkJson ? key.c_str() : getTaskValueName(event->TaskIndex, x).c_str(),
toString(doublePayload, ExtraTaskSettings.TaskDeviceValueDecimals[x]).c_str()));
}
# endif // if !defined(P037_LIMIT_BUILD_SIZE) || defined(P037_OVERRIDE)
// Generate event for rules processing - proposed by TridentTD
@@ -678,6 +661,29 @@ boolean Plugin_037(uint8_t function, struct EventStruct *event, String& string)
}
P037_addEventToQueue(event, RuleEvent);
}
else
{ // Generate event of all non-json topic/payloads
String tmp = unparsedPayload;
tmp.replace('}', '>'); // Replace curly braces by angle brackets to avoid problems with string processing in rules
tmp.replace('{', '<');
String RuleEvent = strformat(F("%s#%s=%s"),
getTaskDeviceName(event->TaskIndex).c_str(),
event->String1.c_str(),
wrapWithQuotesIfContainsParameterSeparatorChar(tmp).c_str());
P037_addEventToQueue(event, RuleEvent);
}
// Log the event
# if !defined(P037_LIMIT_BUILD_SIZE) || defined(P037_OVERRIDE)
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
addLog(LOG_LEVEL_INFO, strformat(F("IMPT : [%s#%s] : %s"),
getTaskDeviceName(event->TaskIndex).c_str(),
checkJson ? key.c_str() : getTaskValueName(event->TaskIndex, x).c_str(),
toString(doublePayload, ExtraTaskSettings.TaskDeviceValueDecimals[x]).c_str()));
}
# endif // if !defined(P037_LIMIT_BUILD_SIZE) || defined(P037_OVERRIDE)
// (Always) Generate <Taskname>#<Valuename>=<Payload> event
String RuleEvent;
@@ -690,7 +696,11 @@ boolean Plugin_037(uint8_t function, struct EventStruct *event, String& string)
if (numericPayload) {
RuleEvent += toString(doublePayload, ExtraTaskSettings.TaskDeviceValueDecimals[x]);
} else {
RuleEvent += wrapWithQuotesIfContainsParameterSeparatorChar(Payload);
String tmp = Payload;
tmp.replace('}', '>'); // Replace curly braces by angle brackets to avoid problems with
tmp.replace('{', '<'); // string processing in rules if a JSON message is received
RuleEvent += wrapWithQuotesIfContainsParameterSeparatorChar(tmp);
}
P037_addEventToQueue(event, RuleEvent);
}