Skip to content
This repository was archived by the owner on Apr 28, 2022. It is now read-only.

Commit 20e6bc5

Browse files
authored
Merge pull request #288 from toblum/develop
v 2.1.8
2 parents af1a8c9 + 8e77f37 commit 20e6bc5

File tree

5 files changed

+26
-6
lines changed

5 files changed

+26
-6
lines changed

Arduino/McLighting/definitions.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ const char HOSTNAME[] = "McLighting01"; // Friedly hostname
2727
uint8_t _sn[4] = {255,255,255,0};
2828
#endif
2929

30+
#ifdef MQTT_HOME_ASSISTANT_SUPPORT
31+
#define MQTT_HOME_ASSISTANT_0_84_SUPPORT // Comment if using HA version < 0.84
32+
#endif
33+
3034
#if defined(USE_WS2812FX_DMA) and defined(USE_WS2812FX_UART)
3135
#error "Cant have both DMA and UART method."
3236
#endif
@@ -50,7 +54,7 @@ uint32_t autoParams[][4] = { // color, speed, mode, duration (seconds)
5054

5155
#if defined(ENABLE_MQTT) or defined(ENABLE_AMQTT)
5256
#ifdef ENABLE_MQTT
53-
#define MQTT_MAX_PACKET_SIZE 512
57+
#define MQTT_MAX_PACKET_SIZE 2048
5458
#define MQTT_MAX_RECONNECT_TRIES 4
5559

5660
int mqtt_reconnect_retries = 0;

Arduino/McLighting/request_handlers.h

+14-4
Original file line numberDiff line numberDiff line change
@@ -936,10 +936,15 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
936936
ha_send_data.detach();
937937
mqtt_client.subscribe(mqtt_ha_state_in.c_str(), qossub);
938938
#ifdef MQTT_HOME_ASSISTANT_SUPPORT
939-
DynamicJsonDocument jsonBuffer(JSON_ARRAY_SIZE(strip.getModeCount()) + JSON_OBJECT_SIZE(11));
939+
DynamicJsonDocument jsonBuffer(JSON_ARRAY_SIZE(strip.getModeCount()) + JSON_OBJECT_SIZE(12));
940940
JsonObject json = jsonBuffer.to<JsonObject>();
941941
json["name"] = HOSTNAME;
942+
#ifdef MQTT_HOME_ASSISTANT_0_84_SUPPORT
943+
json["platform"] = "mqtt";
944+
json["schema"] = "json";
945+
#else
942946
json["platform"] = "mqtt_json";
947+
#endif
943948
json["state_topic"] = mqtt_ha_state_out;
944949
json["command_topic"] = mqtt_ha_state_in;
945950
json["on_command_type"] = "first";
@@ -1016,10 +1021,15 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
10161021
uint16_t packetIdSub2 = amqttClient.subscribe((char *)mqtt_ha_state_in.c_str(), qossub);
10171022
DBG_OUTPUT_PORT.printf("Subscribing at QoS %d, packetId: ", qossub); DBG_OUTPUT_PORT.println(packetIdSub2);
10181023
#ifdef MQTT_HOME_ASSISTANT_SUPPORT
1019-
DynamicJsonDocument jsonBuffer(JSON_ARRAY_SIZE(strip.getModeCount()) + JSON_OBJECT_SIZE(11));
1024+
DynamicJsonDocument jsonBuffer(JSON_ARRAY_SIZE(strip.getModeCount()) + JSON_OBJECT_SIZE(12));
10201025
JsonObject json = jsonBuffer.to<JsonObject>();
10211026
json["name"] = HOSTNAME;
1027+
#ifdef MQTT_HOME_ASSISTANT_0_84_SUPPORT
1028+
json["platform"] = "mqtt";
1029+
json["schema"] = "json";
1030+
#else
10221031
json["platform"] = "mqtt_json";
1032+
#endif
10231033
json["state_topic"] = mqtt_ha_state_out;
10241034
json["command_topic"] = mqtt_ha_state_in;
10251035
json["on_command_type"] = "first";
@@ -1186,7 +1196,7 @@ bool writeConfigFS(bool saveConfig){
11861196
//FS save
11871197
updateFS = true;
11881198
DBG_OUTPUT_PORT.print("Saving config: ");
1189-
DynamicJsonDocument jsonBuffer(JSON_OBJECT_SIZE(4));
1199+
DynamicJsonDocument jsonBuffer;
11901200
JsonObject json = jsonBuffer.to<JsonObject>();
11911201
json["mqtt_host"] = mqtt_host;
11921202
json["mqtt_port"] = mqtt_port;
@@ -1255,7 +1265,7 @@ bool writeStateFS(){
12551265
updateFS = true;
12561266
//save the strip state to FS JSON
12571267
DBG_OUTPUT_PORT.print("Saving cfg: ");
1258-
DynamicJsonDocument jsonBuffer(JSON_OBJECT_SIZE(7));
1268+
DynamicJsonDocument jsonBuffer;
12591269
JsonObject json = jsonBuffer.to<JsonObject>();
12601270
json["mode"] = static_cast<int>(mode);
12611271
json["strip_mode"] = (int) strip.getMode();

Arduino/McLighting/version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
#define SKETCH_VERSION "2.1.7"
1+
#define SKETCH_VERSION "2.1.8"

Arduino/McLighting/version_info.ino

+4
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,8 @@
3131
* - rethink ESP.getChipId implementaion
3232
* - check ArduinoJSON version
3333
* - Try restting prevmode as suggested in #276
34+
*
35+
* 11 Dec 2018 v 2.1.8
36+
* - Fix Auto-Discovery for HA version >= 0.84 #286
37+
* - Fix #283
3438
*/

platformio.ini

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ description = The ESP8266 based multi-client lighting gadget
1717
[common]
1818
build_flags =
1919
-DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH
20+
-DMQTT_MAX_PACKET_SIZE=2048 ; PubSubClient Specific flags
21+
-w ; supress all warnings
2022
monitor_speed = 115200
2123
board_build.flash_mode = dout
2224
upload_speed = 115200

0 commit comments

Comments
 (0)