diff --git a/src/main.cpp b/src/main.cpp index 264924d..f2f1b82 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -29,6 +29,7 @@ const int idxhum = CONFIG_MQTT_IDX_Hum; //CustomMqtt const char* custom_temperature_topic = CONFIG_MQTT_Temp_TOPIC; const char* custom_humidity_topic = CONFIG_MQTT_Hum_TOPIC ; +const char* custom_combi_topic = CONFIG_MQTT_Comb_TOPIC ; WiFiClient espClient; PubSubClient client(espClient); @@ -169,6 +170,12 @@ void loop() //Custom Mqtt if (CONFIG_CUSTOM_MSG == 1){ + StaticJsonDocument<100> JSONCustomComb; + JSONCustomComb["humidity"] = roundf(CalcHumidity * 100) / 100; + JSONCustomComb["temperature"] = roundf(cTemp * 100) / 100; + char buffer4[256]; + serializeJson(JSONCustomComb, buffer4); + if (client.publish(custom_temperature_topic, String(cTemp).c_str(), true) == true) { Serial.println("Published Custom MQTT messages"); } else { @@ -176,6 +183,7 @@ void loop() } client.publish(custom_humidity_topic, String(CalcHumidity).c_str(), true); + client.publish(custom_combi_topic, buffer4); client.loop(); delay(60000); //1min }