From 183d8455971b68be2d0ce11642c2f78c52bac9fc Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 27 Sep 2019 19:53:45 +0200 Subject: [PATCH] show MQTT subscribes at boot --- src/ems-esp.cpp | 30 ++++++++++++++---------------- src/ems.cpp | 12 +++++------- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/src/ems-esp.cpp b/src/ems-esp.cpp index ee5a772a9..4aba6d393 100644 --- a/src/ems-esp.cpp +++ b/src/ems-esp.cpp @@ -1628,35 +1628,33 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) { // subscribe to the 4 heating circuits char topic_s[50]; char buffer[4]; - for (uint8_t hc = 0; hc < EMS_THERMOSTAT_MAXHC; hc++) { + + // subscribe to the normal batch to be backwards compatible + myESP.mqttSubscribe(TOPIC_THERMOSTAT_CMD_TEMP); + myESP.mqttSubscribe(TOPIC_THERMOSTAT_CMD_MODE); + myESP.mqttSubscribe(TOPIC_THERMOSTAT_CMD_DAYTEMP); + myESP.mqttSubscribe(TOPIC_THERMOSTAT_CMD_NIGHTTEMP); + myESP.mqttSubscribe(TOPIC_THERMOSTAT_CMD_HOLIDAYTEMP); + + for (uint8_t hc = 1; hc <= EMS_THERMOSTAT_MAXHC; hc++) { strlcpy(topic_s, TOPIC_THERMOSTAT_CMD_TEMP, sizeof(topic_s)); - if (hc) { - strlcat(topic_s, itoa(hc, buffer, 10), sizeof(topic_s)); // add 1-4 at the end - } + strlcat(topic_s, itoa(hc, buffer, 10), sizeof(topic_s)); // add 1-4 at the end myESP.mqttSubscribe(topic_s); strlcpy(topic_s, TOPIC_THERMOSTAT_CMD_MODE, sizeof(topic_s)); - if (hc) { - strlcat(topic_s, itoa(hc, buffer, 10), sizeof(topic_s)); // add 1-4 at the end - } + strlcat(topic_s, itoa(hc, buffer, 10), sizeof(topic_s)); // add 1-4 at the end myESP.mqttSubscribe(topic_s); strlcpy(topic_s, TOPIC_THERMOSTAT_CMD_DAYTEMP, sizeof(topic_s)); - if (hc) { - strlcat(topic_s, itoa(hc, buffer, 10), sizeof(topic_s)); // add 1-4 at the end - } + strlcat(topic_s, itoa(hc, buffer, 10), sizeof(topic_s)); // add 1-4 at the end myESP.mqttSubscribe(topic_s); strlcpy(topic_s, TOPIC_THERMOSTAT_CMD_NIGHTTEMP, sizeof(topic_s)); - if (hc) { - strlcat(topic_s, itoa(hc, buffer, 10), sizeof(topic_s)); // add 1-4 at the end - } + strlcat(topic_s, itoa(hc, buffer, 10), sizeof(topic_s)); // add 1-4 at the end myESP.mqttSubscribe(topic_s); strlcpy(topic_s, TOPIC_THERMOSTAT_CMD_HOLIDAYTEMP, sizeof(topic_s)); - if (hc) { - strlcat(topic_s, itoa(hc, buffer, 10), sizeof(topic_s)); // add 1-4 at the end - } + strlcat(topic_s, itoa(hc, buffer, 10), sizeof(topic_s)); // add 1-4 at the end myESP.mqttSubscribe(topic_s); } diff --git a/src/ems.cpp b/src/ems.cpp index 746337425..e1b611745 100644 --- a/src/ems.cpp +++ b/src/ems.cpp @@ -1979,13 +1979,11 @@ void _process_Version(_EMS_RxTelegram * EMS_RxTelegram) { if (typeFound) { // its a known thermostat - if (EMS_Sys_Status.emsLogging >= EMS_SYS_LOGGING_BASIC) { - myDebug_P(PSTR("Thermostat found: %s (DeviceID:0x%02X ProductID:%d Version:%s)"), - Thermostat_Devices[i].model_string, - Thermostat_Devices[i].device_id, - product_id, - version); - } + myDebug_P(PSTR("Thermostat found: %s (DeviceID:0x%02X ProductID:%d Version:%s)"), + Thermostat_Devices[i].model_string, + Thermostat_Devices[i].device_id, + product_id, + version); // add to list _addDevice(EMS_MODELTYPE_THERMOSTAT, product_id, Thermostat_Devices[i].device_id, version, Thermostat_Devices[i].model_string); // type 2 = thermostat