mirror of https://github.com/arendst/Tasmota.git
Add rule support for single JSON value pair
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)
This commit is contained in:
parent
68c076147f
commit
038079a865
|
@ -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)
|
* 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)
|
* 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 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
|
* 6.5.0.9 20190418
|
||||||
* Add command SetOption63 0/1 to disable relay state feedback scan at restart (#5594, #5663)
|
* Add command SetOption63 0/1 to disable relay state feedback scan at restart (#5594, #5663)
|
||||||
|
|
|
@ -2358,7 +2358,7 @@ void SerialInput(void)
|
||||||
ResponseAppend_P(PSTR("\"}"));
|
ResponseAppend_P(PSTR("\"}"));
|
||||||
}
|
}
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_SERIALRECEIVED));
|
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_SERIALRECEIVED));
|
||||||
// XdrvRulesProcess();
|
XdrvRulesProcess();
|
||||||
serial_in_byte_counter = 0;
|
serial_in_byte_counter = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -392,6 +392,15 @@ bool RulesProcessEvent(char *json_event)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
String event_saved = json_event;
|
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();
|
event_saved.toUpperCase();
|
||||||
|
|
||||||
//AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RUL: Event %s"), event_saved.c_str());
|
//AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RUL: Event %s"), event_saved.c_str());
|
||||||
|
|
Loading…
Reference in New Issue