Merge pull request #12496 from barbudor/event_json

EVENT support JSON payload
This commit is contained in:
Theo Arends 2021-06-29 10:36:18 +02:00 committed by GitHub
commit 744b83dae2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -913,7 +913,10 @@ void RulesEvery50ms(void)
} else {
parameter = event + strlen(event); // '\0'
}
snprintf_P(json_event, sizeof(json_event), PSTR("{\"Event\":{\"%s\":\"%s\"}}"), event, parameter);
if (parameter[0]=='{')
snprintf_P(json_event, sizeof(json_event), PSTR("{\"Event\":{\"%s\":%s}}"), event, parameter);
else
snprintf_P(json_event, sizeof(json_event), PSTR("{\"Event\":{\"%s\":\"%s\"}}"), event, parameter);
Rules.event_data[0] ='\0';
RulesProcessEvent(json_event);
} else {