From 652ff236f6799c3d1c808b59c2752f6f0957fb47 Mon Sep 17 00:00:00 2001
From: Debashish Sahu <debashish.sahu@gmail.com>
Date: Mon, 11 Feb 2019 17:31:12 -0500
Subject: [PATCH] ArduinoJSON 6.8.0-beta

- ArduinoJSON 6.8.0-beta
- Update version_info
---
 Arduino/McLighting/McLighting.ino     | 8 ++++----
 Arduino/McLighting/request_handlers.h | 6 +++---
 Arduino/McLighting/version_info.ino   | 1 +
 platformio.ini                        | 2 +-
 4 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/Arduino/McLighting/McLighting.ino b/Arduino/McLighting/McLighting.ino
index f4a99a1..661bf72 100644
--- a/Arduino/McLighting/McLighting.ino
+++ b/Arduino/McLighting/McLighting.ino
@@ -53,8 +53,8 @@
 #endif
 
 #ifdef ARDUINOJSON_VERSION
-  #if !(ARDUINOJSON_VERSION_MAJOR == 6 and ARDUINOJSON_VERSION_MINOR == 7)
-    #error "Install ArduinoJson v6.7.0-beta"
+  #if !(ARDUINOJSON_VERSION_MAJOR == 6 and ARDUINOJSON_VERSION_MINOR == 8)
+    #error "Install ArduinoJson v6.8.0-beta"
   #endif
 #endif
 
@@ -548,7 +548,7 @@ void setup() {
   }, handleFileUpload);
   //get heap status, analog input value and all GPIO statuses in one json call
   server.on("/esp_status", HTTP_GET, []() {
-    DynamicJsonDocument jsonBuffer;
+    DynamicJsonDocument jsonBuffer(JSON_OBJECT_SIZE(21) + 1500);
     JsonObject json = jsonBuffer.to<JsonObject>();
   
     json["HOSTNAME"] = HOSTNAME;
@@ -805,7 +805,7 @@ void setup() {
       #endif
     }
 
-    DynamicJsonDocument jsonBuffer;
+    DynamicJsonDocument jsonBuffer(200);
     JsonObject json = jsonBuffer.to<JsonObject>();
     json["pixel_pount"] = WS2812FXStripSettings.stripSize;
     json["rgb_order"] = WS2812FXStripSettings.RGBOrder;
diff --git a/Arduino/McLighting/request_handlers.h b/Arduino/McLighting/request_handlers.h
index 327b7a1..0ae837f 100644
--- a/Arduino/McLighting/request_handlers.h
+++ b/Arduino/McLighting/request_handlers.h
@@ -1275,7 +1275,7 @@ bool writeConfigFS(bool saveConfig){
     //FS save
     updateFS = true;
     DBG_OUTPUT_PORT.print("Saving config: ");
-    DynamicJsonDocument jsonBuffer;
+    DynamicJsonDocument jsonBuffer(200);
     JsonObject json = jsonBuffer.to<JsonObject>();
     json["mqtt_host"] = mqtt_host;
     json["mqtt_port"] = mqtt_port;
@@ -1344,7 +1344,7 @@ bool writeStateFS(){
   updateFS = true;
   //save the strip state to FS JSON
   DBG_OUTPUT_PORT.print("Saving cfg: ");
-  DynamicJsonDocument jsonBuffer;
+  DynamicJsonDocument jsonBuffer(JSON_OBJECT_SIZE(7)+200);
   JsonObject json = jsonBuffer.to<JsonObject>();
   json["mode"] = static_cast<int>(mode);
   json["strip_mode"] = (int) strip->getMode();
@@ -1492,7 +1492,7 @@ void writeStripConfigFS(void){
   updateFS = true;
   //save the strip config to FS JSON
   DBG_OUTPUT_PORT.print("Saving cfg: ");
-  DynamicJsonDocument jsonBuffer;
+  DynamicJsonDocument jsonBuffer(JSON_OBJECT_SIZE(4)+300);
   JsonObject json = jsonBuffer.to<JsonObject>();
   json["pixel_pount"] = WS2812FXStripSettings.stripSize;
   json["rgb_order"] = WS2812FXStripSettings.RGBOrder;
diff --git a/Arduino/McLighting/version_info.ino b/Arduino/McLighting/version_info.ino
index 776b466..b7962ce 100644
--- a/Arduino/McLighting/version_info.ino
+++ b/Arduino/McLighting/version_info.ino
@@ -69,4 +69,5 @@
  * - new "REST API": /pixels?ct=xxx to change length of LED strip
  * - new "REST API": /pixels?rgbo=xxx to change RGB order
  * - new "REST API": /pixels?pin=GPIO_NO to change PIN# (Allowed GPIO values: 16/5/4/0/2/14/12/13/15/3/1)
+ * - added HA 0.87 version support https://github.com/toblum/McLighting/issues/327
  */
diff --git a/platformio.ini b/platformio.ini
index b0fd6ad..a6f56da 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -37,7 +37,7 @@ upload_resetmethod = nodemcu
 lib_deps =
   WiFiManager@0.14
   AsyncMqttClient
-  https://github.com/bblanchon/ArduinoJson.git#v6.7.0-beta
+  https://github.com/bblanchon/ArduinoJson.git#v6.8.0-beta
   WS2812FX
   NeoPixelBus@2.4.1
   WebSockets