From 814f477cf9c9851dce4a48283a24483d300bcef9 Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 27 Sep 2019 10:19:10 +0200 Subject: [PATCH] quick adjustment to MQTT HC - https://github.com/proddy/EMS-ESP/commit/1549cf5e75be64a6dd141e8cb861037340260f13 --- src/ems-esp.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ems-esp.cpp b/src/ems-esp.cpp index 5313c0e75..def52ba85 100644 --- a/src/ems-esp.cpp +++ b/src/ems-esp.cpp @@ -839,7 +839,8 @@ void publishValues(bool force) { // handle the thermostat values if (ems_getThermostatEnabled()) { - uint8_t total_active_hc = 0; // number of HCs + uint8_t total_active_hc = 0; // number of HCs + bool hc_1_active = EMS_Thermostat.hc[0].active; // do we have HC1 active? for (uint8_t hc_v = 1; hc_v <= EMS_THERMOSTAT_MAXHC; hc_v++) { _EMS_Thermostat_HC * thermostat = &EMS_Thermostat.hc[hc_v - 1]; @@ -916,8 +917,10 @@ void publishValues(bool force) { previousThermostatPublishCRC = fchecksum; char thermostat_topicname[20]; strlcpy(thermostat_topicname, TOPIC_THERMOSTAT_DATA, sizeof(thermostat_topicname)); // "thermostat_data" - // if we have more than 1 active Heating Circuit, postfix with the HC number - if (total_active_hc > 1) { + // if we have more than 1 active Heating Circuit + // or this is single HC and its not HC1 + // append topic name with the HC number + if ((total_active_hc > 1) || ((total_active_hc == 1) && (!hc_1_active))) { char buffer[4]; strlcat(thermostat_topicname, itoa(total_active_hc, buffer, 10), sizeof(thermostat_topicname)); }