@@ -936,10 +936,15 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
936
936
ha_send_data.detach ();
937
937
mqtt_client.subscribe (mqtt_ha_state_in.c_str (), qossub);
938
938
#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 ));
940
940
JsonObject json = jsonBuffer.to <JsonObject>();
941
941
json[" name" ] = HOSTNAME;
942
+ #ifdef MQTT_HOME_ASSISTANT_0_84_SUPPORT
943
+ json[" platform" ] = " mqtt" ;
944
+ json[" schema" ] = " json" ;
945
+ #else
942
946
json[" platform" ] = " mqtt_json" ;
947
+ #endif
943
948
json[" state_topic" ] = mqtt_ha_state_out;
944
949
json[" command_topic" ] = mqtt_ha_state_in;
945
950
json[" on_command_type" ] = " first" ;
@@ -1016,10 +1021,15 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
1016
1021
uint16_t packetIdSub2 = amqttClient.subscribe ((char *)mqtt_ha_state_in.c_str (), qossub);
1017
1022
DBG_OUTPUT_PORT.printf (" Subscribing at QoS %d, packetId: " , qossub); DBG_OUTPUT_PORT.println (packetIdSub2);
1018
1023
#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 ));
1020
1025
JsonObject json = jsonBuffer.to <JsonObject>();
1021
1026
json[" name" ] = HOSTNAME;
1027
+ #ifdef MQTT_HOME_ASSISTANT_0_84_SUPPORT
1028
+ json[" platform" ] = " mqtt" ;
1029
+ json[" schema" ] = " json" ;
1030
+ #else
1022
1031
json[" platform" ] = " mqtt_json" ;
1032
+ #endif
1023
1033
json[" state_topic" ] = mqtt_ha_state_out;
1024
1034
json[" command_topic" ] = mqtt_ha_state_in;
1025
1035
json[" on_command_type" ] = " first" ;
@@ -1186,7 +1196,7 @@ bool writeConfigFS(bool saveConfig){
1186
1196
// FS save
1187
1197
updateFS = true ;
1188
1198
DBG_OUTPUT_PORT.print (" Saving config: " );
1189
- DynamicJsonDocument jsonBuffer ( JSON_OBJECT_SIZE ( 4 )) ;
1199
+ DynamicJsonDocument jsonBuffer;
1190
1200
JsonObject json = jsonBuffer.to <JsonObject>();
1191
1201
json[" mqtt_host" ] = mqtt_host;
1192
1202
json[" mqtt_port" ] = mqtt_port;
@@ -1255,7 +1265,7 @@ bool writeStateFS(){
1255
1265
updateFS = true ;
1256
1266
// save the strip state to FS JSON
1257
1267
DBG_OUTPUT_PORT.print (" Saving cfg: " );
1258
- DynamicJsonDocument jsonBuffer ( JSON_OBJECT_SIZE ( 7 )) ;
1268
+ DynamicJsonDocument jsonBuffer;
1259
1269
JsonObject json = jsonBuffer.to <JsonObject>();
1260
1270
json[" mode" ] = static_cast <int >(mode);
1261
1271
json[" strip_mode" ] = (int ) strip.getMode ();
0 commit comments