Merge branch 'mega' of https://github.com/letscontrolit/ESPEasy into feature/P157-plugin-14-segment-display

This commit is contained in:
Ton Huisman
2026-08-09 21:38:27 +02:00
5 changed files with 41 additions and 22 deletions
+1 -1
View File
@@ -173,7 +173,7 @@ def generateBuildOverview(fileName):
print('Writing build sets overview to:', filepath)
output = open(filepath, "w")
output = open(filepath, "w", encoding="utf-8")
output.write('Plugins per build set\n')
output.write('=====================\n')
output.write('\n')
+1 -1
View File
@@ -1,5 +1,5 @@
pioarduino==6.1.19
pygit2>=1.10.1
cryptography==44.0.1
cryptography==50.0.0
setuptools>=75.8
uv
+26 -20
View File
@@ -632,25 +632,6 @@ 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
if (Settings.UseRules && P037_SEND_EVENTS) {
@@ -678,6 +659,28 @@ 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;
addEscapeCharacters(tmp); // Add escape characters to avoid problems with rules processing if a JSON message is received
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 +693,10 @@ 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;
addEscapeCharacters(tmp); // Add escape characters to avoid problems with rules processing if a JSON message is received
RuleEvent += wrapWithQuotesIfContainsParameterSeparatorChar(tmp);
}
P037_addEventToQueue(event, RuleEvent);
}
+11
View File
@@ -46,6 +46,17 @@ void stripEscapeCharacters(String& str)
}
}
void addEscapeCharacters(String& str)
{
const char braces[] = { '%', '[', ']', '{', '}', '(', ')' };
constexpr uint8_t nrbraces = NR_ELEMENTS(braces);
for (uint8_t i = 0; i < nrbraces; ++i) {
const String s(concat(F("\\"), braces[i]));
str.replace(s.substring(1), s);
}
}
#if FEATURE_STRING_VARIABLES
String parseTemplateAndCalculate(String& tmpString) {
stripEscapeCharacters(tmpString);
+2
View File
@@ -15,6 +15,8 @@ bool hasEscapedCharacter(String& str, const char EscapeChar);
// So far \\% \\[ \\] \\{ \\} \\( and \\) are used (all with single backslash!)
void stripEscapeCharacters(String& str);
void addEscapeCharacters(String& str);
#if FEATURE_STRING_VARIABLES
String parseTemplateAndCalculate(String& tmpString);
uint8_t getDerivedValueCountForTask(taskIndex_t taskIndex);