commit
20e6bc5c57
5 changed files with 26 additions and 6 deletions
|
@ -27,6 +27,10 @@ const char HOSTNAME[] = "McLighting01"; // Friedly hostname
|
||||||
uint8_t _sn[4] = {255,255,255,0};
|
uint8_t _sn[4] = {255,255,255,0};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MQTT_HOME_ASSISTANT_SUPPORT
|
||||||
|
#define MQTT_HOME_ASSISTANT_0_84_SUPPORT // Comment if using HA version < 0.84
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(USE_WS2812FX_DMA) and defined(USE_WS2812FX_UART)
|
#if defined(USE_WS2812FX_DMA) and defined(USE_WS2812FX_UART)
|
||||||
#error "Cant have both DMA and UART method."
|
#error "Cant have both DMA and UART method."
|
||||||
#endif
|
#endif
|
||||||
|
@ -50,7 +54,7 @@ uint32_t autoParams[][4] = { // color, speed, mode, duration (seconds)
|
||||||
|
|
||||||
#if defined(ENABLE_MQTT) or defined(ENABLE_AMQTT)
|
#if defined(ENABLE_MQTT) or defined(ENABLE_AMQTT)
|
||||||
#ifdef ENABLE_MQTT
|
#ifdef ENABLE_MQTT
|
||||||
#define MQTT_MAX_PACKET_SIZE 512
|
#define MQTT_MAX_PACKET_SIZE 2048
|
||||||
#define MQTT_MAX_RECONNECT_TRIES 4
|
#define MQTT_MAX_RECONNECT_TRIES 4
|
||||||
|
|
||||||
int mqtt_reconnect_retries = 0;
|
int mqtt_reconnect_retries = 0;
|
||||||
|
|
|
@ -936,10 +936,15 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
||||||
ha_send_data.detach();
|
ha_send_data.detach();
|
||||||
mqtt_client.subscribe(mqtt_ha_state_in.c_str(), qossub);
|
mqtt_client.subscribe(mqtt_ha_state_in.c_str(), qossub);
|
||||||
#ifdef MQTT_HOME_ASSISTANT_SUPPORT
|
#ifdef MQTT_HOME_ASSISTANT_SUPPORT
|
||||||
DynamicJsonDocument jsonBuffer(JSON_ARRAY_SIZE(strip.getModeCount()) + JSON_OBJECT_SIZE(11));
|
DynamicJsonDocument jsonBuffer(JSON_ARRAY_SIZE(strip.getModeCount()) + JSON_OBJECT_SIZE(12));
|
||||||
JsonObject json = jsonBuffer.to<JsonObject>();
|
JsonObject json = jsonBuffer.to<JsonObject>();
|
||||||
json["name"] = HOSTNAME;
|
json["name"] = HOSTNAME;
|
||||||
|
#ifdef MQTT_HOME_ASSISTANT_0_84_SUPPORT
|
||||||
|
json["platform"] = "mqtt";
|
||||||
|
json["schema"] = "json";
|
||||||
|
#else
|
||||||
json["platform"] = "mqtt_json";
|
json["platform"] = "mqtt_json";
|
||||||
|
#endif
|
||||||
json["state_topic"] = mqtt_ha_state_out;
|
json["state_topic"] = mqtt_ha_state_out;
|
||||||
json["command_topic"] = mqtt_ha_state_in;
|
json["command_topic"] = mqtt_ha_state_in;
|
||||||
json["on_command_type"] = "first";
|
json["on_command_type"] = "first";
|
||||||
|
@ -1016,10 +1021,15 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
||||||
uint16_t packetIdSub2 = amqttClient.subscribe((char *)mqtt_ha_state_in.c_str(), qossub);
|
uint16_t packetIdSub2 = amqttClient.subscribe((char *)mqtt_ha_state_in.c_str(), qossub);
|
||||||
DBG_OUTPUT_PORT.printf("Subscribing at QoS %d, packetId: ", qossub); DBG_OUTPUT_PORT.println(packetIdSub2);
|
DBG_OUTPUT_PORT.printf("Subscribing at QoS %d, packetId: ", qossub); DBG_OUTPUT_PORT.println(packetIdSub2);
|
||||||
#ifdef MQTT_HOME_ASSISTANT_SUPPORT
|
#ifdef MQTT_HOME_ASSISTANT_SUPPORT
|
||||||
DynamicJsonDocument jsonBuffer(JSON_ARRAY_SIZE(strip.getModeCount()) + JSON_OBJECT_SIZE(11));
|
DynamicJsonDocument jsonBuffer(JSON_ARRAY_SIZE(strip.getModeCount()) + JSON_OBJECT_SIZE(12));
|
||||||
JsonObject json = jsonBuffer.to<JsonObject>();
|
JsonObject json = jsonBuffer.to<JsonObject>();
|
||||||
json["name"] = HOSTNAME;
|
json["name"] = HOSTNAME;
|
||||||
|
#ifdef MQTT_HOME_ASSISTANT_0_84_SUPPORT
|
||||||
|
json["platform"] = "mqtt";
|
||||||
|
json["schema"] = "json";
|
||||||
|
#else
|
||||||
json["platform"] = "mqtt_json";
|
json["platform"] = "mqtt_json";
|
||||||
|
#endif
|
||||||
json["state_topic"] = mqtt_ha_state_out;
|
json["state_topic"] = mqtt_ha_state_out;
|
||||||
json["command_topic"] = mqtt_ha_state_in;
|
json["command_topic"] = mqtt_ha_state_in;
|
||||||
json["on_command_type"] = "first";
|
json["on_command_type"] = "first";
|
||||||
|
@ -1186,7 +1196,7 @@ bool writeConfigFS(bool saveConfig){
|
||||||
//FS save
|
//FS save
|
||||||
updateFS = true;
|
updateFS = true;
|
||||||
DBG_OUTPUT_PORT.print("Saving config: ");
|
DBG_OUTPUT_PORT.print("Saving config: ");
|
||||||
DynamicJsonDocument jsonBuffer(JSON_OBJECT_SIZE(4));
|
DynamicJsonDocument jsonBuffer;
|
||||||
JsonObject json = jsonBuffer.to<JsonObject>();
|
JsonObject json = jsonBuffer.to<JsonObject>();
|
||||||
json["mqtt_host"] = mqtt_host;
|
json["mqtt_host"] = mqtt_host;
|
||||||
json["mqtt_port"] = mqtt_port;
|
json["mqtt_port"] = mqtt_port;
|
||||||
|
@ -1255,7 +1265,7 @@ bool writeStateFS(){
|
||||||
updateFS = true;
|
updateFS = true;
|
||||||
//save the strip state to FS JSON
|
//save the strip state to FS JSON
|
||||||
DBG_OUTPUT_PORT.print("Saving cfg: ");
|
DBG_OUTPUT_PORT.print("Saving cfg: ");
|
||||||
DynamicJsonDocument jsonBuffer(JSON_OBJECT_SIZE(7));
|
DynamicJsonDocument jsonBuffer;
|
||||||
JsonObject json = jsonBuffer.to<JsonObject>();
|
JsonObject json = jsonBuffer.to<JsonObject>();
|
||||||
json["mode"] = static_cast<int>(mode);
|
json["mode"] = static_cast<int>(mode);
|
||||||
json["strip_mode"] = (int) strip.getMode();
|
json["strip_mode"] = (int) strip.getMode();
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
#define SKETCH_VERSION "2.1.7"
|
#define SKETCH_VERSION "2.1.8"
|
||||||
|
|
|
@ -31,4 +31,8 @@
|
||||||
* - rethink ESP.getChipId implementaion
|
* - rethink ESP.getChipId implementaion
|
||||||
* - check ArduinoJSON version
|
* - check ArduinoJSON version
|
||||||
* - Try restting prevmode as suggested in #276
|
* - Try restting prevmode as suggested in #276
|
||||||
|
*
|
||||||
|
* 11 Dec 2018 v 2.1.8
|
||||||
|
* - Fix Auto-Discovery for HA version >= 0.84 #286
|
||||||
|
* - Fix #283
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -17,6 +17,8 @@ description = The ESP8266 based multi-client lighting gadget
|
||||||
[common]
|
[common]
|
||||||
build_flags =
|
build_flags =
|
||||||
-DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH
|
-DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH
|
||||||
|
-DMQTT_MAX_PACKET_SIZE=2048 ; PubSubClient Specific flags
|
||||||
|
-w ; supress all warnings
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
board_build.flash_mode = dout
|
board_build.flash_mode = dout
|
||||||
upload_speed = 115200
|
upload_speed = 115200
|
||||||
|
|
Loading…
Reference in a new issue