add json value for rules (#20718)

This commit is contained in:
Barbudor 2024-02-13 13:52:48 +01:00 committed by GitHub
parent 71ae3fb231
commit 04cd8950a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -709,7 +709,7 @@ void RulesVarReplace(String &commands, const String &sfind, const String &replac
/*******************************************************************************************/
bool RuleSetProcess(uint8_t rule_set, String &event_saved)
bool RuleSetProcess(uint8_t rule_set, String &event_saved, const char *json_event)
{
bool serviced = false;
char stemp[10];
@ -798,6 +798,7 @@ bool RuleSetProcess(uint8_t rule_set, String &event_saved)
snprintf_P(stemp, sizeof(stemp), PSTR("%06X"), ESP_getChipId());
RulesVarReplace(commands, F("%DEVICEID%"), stemp);
RulesVarReplace(commands, F("%MACADDR%"), NetworkUniqueId());
RulesVarReplace(commands, F("%JSON%"), json_event);
#if defined(USE_TIMERS)
for (uint32_t i = 0; i < MAX_TIMERS; i++) {
snprintf_P(stemp, sizeof(stemp), PSTR("%%TIMER%d%%"), i +1);
@ -908,7 +909,7 @@ bool RulesProcessEvent(const char *json_event)
for (uint32_t i = 0; i < MAX_RULE_SETS; i++) {
if (GetRuleLen(i) && bitRead(Settings->rule_enabled, i)) {
if (RuleSetProcess(i, event_saved)) { serviced = true; }
if (RuleSetProcess(i, event_saved, json_event)) { serviced = true; }
}
}