diff --git a/CHANGELOG.md b/CHANGELOG.md index dbbb98f2d..4581c0ab4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/wled00/mqtt.cpp b/wled00/mqtt.cpp index 546d9d06e..15cb0c5df 100644 --- a/wled00/mqtt.cpp +++ b/wled00/mqtt.cpp @@ -85,9 +85,15 @@ void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties colorUpdated(NOTIFIER_CALL_MODE_DIRECT_CHANGE); } else if (strcmp(topic, "/api") == 0) { - String apireq = "win&"; - apireq += (char*)payload; - handleSet(nullptr, apireq); + if (payload[0] == '{') { //JSON API + DynamicJsonDocument doc(JSON_BUFFER_SIZE); + deserializeJson(doc, payload); + deserializeState(doc.as()); + } else { //HTTP API + String apireq = "win&"; + apireq += (char*)payload; + handleSet(nullptr, apireq); + } } else if (strcmp(topic, "") == 0) { parseMQTTBriPayload(payload); diff --git a/wled00/wled.h b/wled00/wled.h index 55bdb7282..064a1f2b0 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -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).