Add JSON receiving to MQTT /api

This commit is contained in:
cschwinne 2020-11-12 09:13:08 +01:00
parent 1b3ed80d37
commit 560f72a320
3 changed files with 14 additions and 4 deletions

View File

@ -2,6 +2,10 @@
### Development versions after the 0.10.2 release
#### Build 2011120
- Added the ability for the /api MQTT topic to receive JSON API payloads
#### Build 2011040
- Inversed Rain direction (fixes #1147)

View File

@ -85,9 +85,15 @@ void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties
colorUpdated(NOTIFIER_CALL_MODE_DIRECT_CHANGE);
} else if (strcmp(topic, "/api") == 0)
{
if (payload[0] == '{') { //JSON API
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
deserializeJson(doc, payload);
deserializeState(doc.as<JsonObject>());
} else { //HTTP API
String apireq = "win&";
apireq += (char*)payload;
handleSet(nullptr, apireq);
}
} else if (strcmp(topic, "") == 0)
{
parseMQTTBriPayload(payload);

View File

@ -8,7 +8,7 @@
*/
// version code in format yymmddb (b = daily build)
#define VERSION 2011040
#define VERSION 2011120
// ESP8266-01 (blue) got too little storage space to work with all features of WLED. To use it, you must use ESP8266 Arduino Core v2.4.2 and the setting 512K(No SPIFFS).