diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino index 68ae053a5..4d6cb27aa 100644 --- a/sonoff/_changelog.ino +++ b/sonoff/_changelog.ino @@ -4,6 +4,7 @@ * Add support for Shelly 1PM Template {"NAME":"Shelly 1PM","GPIO":[56,0,0,0,82,134,0,0,0,0,0,21,0],"FLAG":2,"BASE":18} (#5716) * Fix Sonoff Pow R2 / S31 invalid energy increments (#5789) * Add device OverTemp (>73 Celsius) detection to any Energy Monitoring device with temperature sensor powering off all outputs + * Add rule support for single JSON value pair like {"SSerialReceived":"on"} by expanding it to {"SSerialReceived":{"Data":"on"}} allowing for trigger SSerialReceived#Data=on (#5638) * * 6.5.0.9 20190418 * Add command SetOption63 0/1 to disable relay state feedback scan at restart (#5594, #5663) diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index 049fe688f..a9b664ec6 100755 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -2358,7 +2358,7 @@ void SerialInput(void) ResponseAppend_P(PSTR("\"}")); } MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_SERIALRECEIVED)); -// XdrvRulesProcess(); + XdrvRulesProcess(); serial_in_byte_counter = 0; } } diff --git a/sonoff/xdrv_10_rules.ino b/sonoff/xdrv_10_rules.ino index 17b14ef42..3c0d05d4a 100644 --- a/sonoff/xdrv_10_rules.ino +++ b/sonoff/xdrv_10_rules.ino @@ -392,6 +392,15 @@ bool RulesProcessEvent(char *json_event) #endif String event_saved = json_event; + // json_event = {"INA219":{"Voltage":4.494,"Current":0.020,"Power":0.089}} + // json_event = {"System":{"Boot":1}} + // json_event = {"SerialReceived":"on"} - invalid but will be expanded to {"SerialReceived":{"Data":"on"}} + char *p = strchr(json_event, ':'); + if ((p != NULL) && !(strchr(++p, ':'))) { // Find second colon + event_saved.replace(F(":"), F(":{\"Data\":")); + event_saved += F("}"); + // event_saved = {"SerialReceived":{"Data":"on"}} + } event_saved.toUpperCase(); //AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RUL: Event %s"), event_saved.c_str());